RKM
RKM

Reputation: 3241

How to disable objects in Silverlight?

I want to disable a button in silverlight, does it has a disable property that can bind to a variable?

thanks :)

Upvotes: 1

Views: 118

Answers (2)

Ed Chapel
Ed Chapel

Reputation: 6932

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

Upvotes: 2

keyboardP
keyboardP

Reputation: 69362

To disable a button, you can use

myButton.IsEnabled = false;

All UIElements have this property.

Upvotes: 2

Related Questions