Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two way bind checkbox to boolean property in silverlight

Tags:

silverlight

Is there a way to bind a bool to a checkbox ischecked property, and automatically update this property if the UI changes?

<CheckBox IsChecked="{Binding Path=IsFilterOn}" />

public bool IsFilterOn    {
    get;
    set;
}

What changes do I need to make to this?

like image 330
Shawn Mclean Avatar asked Jan 19 '23 12:01

Shawn Mclean


1 Answers

Put the binding in to two way mode:-

 <CheckBox IsChecked="{Binding Path=IsFilterOn, Mode=TwoWay}" />

If you want the UI to update if other code changes the property on the object you should also implement INotifyPropertyChanged on your object. You will then have full bi-lateral observation on the property.

like image 144
AnthonyWJones Avatar answered Jun 06 '23 17:06

AnthonyWJones