How to disable objects in Silverlight?
I want to dis开发者_如何学运维able a button in silverlight, does it has a disable property that can bind to a variable?
thanks :)
To disable a button, you can use
myButton.IsEnabled = false;
All UIElements have this property.
If you have some sort of ViewModel with a bool
property
public bool CanDoSomething
{
get { return _canDoSomething; }
set
{
if (_canDoSomething != value)
{
_canDoSomething = value;
RaisePropertyChanged("CanDoSomething");
}
}
}
Then you can bind the Button in XAML with something like
<Button IsEnabled="{Binding Path=CanDoSomething}" />
精彩评论