开发者

How to disable objects in Silverlight?

开发者 https://www.devze.com 2023-03-06 02:12 出处:网络
I want to dis开发者_如何学运维able a button in silverlight, does it has a disable property that can bind to a variable?

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}" />
0

精彩评论

暂无评论...
验证码 换一张
取 消