Jose Simas
Top achievements
Rank 2
Jose Simas
asked on 11 May 2011, 11:38 AM
Hi,
I have this XAML:
<telerik1:RadSplitButton
Content="Some Label"
IsEnabled="{Binding SomeProperty}"
Command="{Binding MyCommand}"
....
Where MyCommand is a DelegateCommand class where the CanExecute method returns True. The problem is that the IsEnabled in the XAML is ignored and the button is always enabled even if SomeProperty's value is false.
This is unexpected because it does not happen with other controls like the standard Button. I was going to post a bug report but I am not sure if this is by design.
Jose
I have this XAML:
<telerik1:RadSplitButton
Content="Some Label"
IsEnabled="{Binding SomeProperty}"
Command="{Binding MyCommand}"
....
Where MyCommand is a DelegateCommand class where the CanExecute method returns True. The problem is that the IsEnabled in the XAML is ignored and the button is always enabled even if SomeProperty's value is false.
This is unexpected because it does not happen with other controls like the standard Button. I was going to post a bug report but I am not sure if this is by design.
Jose
5 Answers, 1 is accepted
0
Hi Jose Simas,
The behavior you have encountered is expected. The way to disable your RadButton (or RadSplitButton in your case) when using ICommand is to return false in the CanExecute method. For example like so:
Let us know if you need more info on this.
Kind regards,
Petar Mladenov
the Telerik team
The behavior you have encountered is expected. The way to disable your RadButton (or RadSplitButton in your case) when using ICommand is to return false in the CanExecute method. For example like so:
<
telerik:RadSplitButton
Command
=
"{Binding MyCommand}"
CommandParameter
=
"ParameterValue"
Content
=
"RadButton"
/>
this
.MyCommand =
new
DelegateCommand((a) => { MessageBox.Show(a.ToString()); }, x => {
return
false
; });
Kind regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jose Simas
Top achievements
Rank 2
answered on 16 May 2011, 02:14 PM
Hi Petar Mladenov,
Thank you for your answer. I have come across several occasions where CanExecute is not enough and I need to disable the button depending on the outcome of some unrelated process. With a regular button I bind IsEnabled to a property that triggers a PropertyChanged and thus can change the button state any time I need. With the SplitButton I cannot do this and I have to forego commands and use events instead.
Best Regards,
Jose
Thank you for your answer. I have come across several occasions where CanExecute is not enough and I need to disable the button depending on the outcome of some unrelated process. With a regular button I bind IsEnabled to a property that triggers a PropertyChanged and thus can change the button state any time I need. With the SplitButton I cannot do this and I have to forego commands and use events instead.
Best Regards,
Jose
0
Hi Jose Simas,
We had a discussion and we logged this issue as a bug in our PITS(Buttons: IsEnabled property should be with higher priority than returned value from CanExecute method of a Command) where you are able to track its status. We also updated your telerik account points.
Thank you for your cooperation.
Best wishes,
Petar Mladenov
the Telerik team
We had a discussion and we logged this issue as a bug in our PITS(Buttons: IsEnabled property should be with higher priority than returned value from CanExecute method of a Command) where you are able to track its status. We also updated your telerik account points.
Thank you for your cooperation.
Best wishes,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rayne
Top achievements
Rank 1
answered on 23 Feb 2012, 05:00 PM
In your Property Setter can you not call InvalidateCanExecute (if using Telerik's DelegateCommand) after you set the property. Then CanExecute can return true or false based on the new value of the property. This would sync the change of the property to the CanExecute method for the command. You could actually call InvalidateCanExecute anytime you need within your ViewModel to enable/disable the command and thus the button.
Might be a work around til they can elevate the IsEnabled priority.
Might be a work around til they can elevate the IsEnabled priority.
0
Hello,
The problem with the IsEnabled and CanExecute is fixed in our latest official build (Q1 2012) and I've attached a sample project which demonstrates this.
If you have more questions please feel free to ask.
Kind regards,
Zarko
the Telerik team
The problem with the IsEnabled and CanExecute is fixed in our latest official build (Q1 2012) and I've attached a sample project which demonstrates this.
If you have more questions please feel free to ask.
Kind regards,
Zarko
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>