Hello Tomas,
Thank you for pointing out this inconsistency. Let me put my two cents in the topic. IMHO, mixing the
Command and
IsEnabled properties of a Button is not a good practice and we strongly advocate against it since the commanding mechanism internally controls the IsEnabled property of the Button. Therefore, a cleaner way will be to use the Command property and take advantage of the CanExecute method to control the IsEnabled property. Take for example the following scenario.
public class ProductViewModel : INotifyPropertyChanged
{
private bool isLoadProperty;
public ProductViewModel()
{
this.LoadCommand = new DelegateCommand(this.LoadProducts, this.CanLoadProducts);
}
public DelegateCommand LoadCommand { get; set; }
private void LoadProducts(object param)
{
}
private bool CanLoadProducts(object param)
{
return this.IsLoadEnabled;
}
public bool IsLoadEnabled
{
get
{
return this.isLoadProperty;
}
set
{
if (this.isLoadProperty != value)
{
this.isLoadProperty = value;
this.LoadCommand.InvalidateCanExecute();
this.OnPropertyChanged("IsLoadEnabled");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyname)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyname));
}
}
}
Clicking the CheckBox will result in the following
outcome. We will further investigate the topic and see why RadButton behaves differently than Button, but again, you should definitely consider not mixing Command and IsEnabled since this might lead to further issues.
I'm attaching my test project as well. Please take a look at it and let me know what your thoughts are on the subject. I'd be glad to further continue the discussion with you.
Regards,
Kiril Stanoev
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