开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜