WPF checkbox binding

Number8 picture Number8 · May 15, 2009 · Viewed 210.8k times · Source

While it is trivial to store a checkbox's checked state in a variable using the checkbox's Click event, how would I do it via databinding? All the examples I have found have the UI updated from some datasource, or bind one control to another; I want to update a member variable when the checkbox is clicked.

TIA for any pointers...

Answer

Thomas Levesque picture Thomas Levesque · May 15, 2009

You must make your binding bidirectional :

<checkbox IsChecked="{Binding Path=MyProperty, Mode=TwoWay}"/>