Sunday, April 27, 2014

How To Bind a CheckBox inside a ListBox using MVVM in Windows Phone 8

You are not binding the IsChecked property of the CheckBox to the view model property. If the IsChecked property belongs to the same class as the ShoppingItems and SelectedItem properties, you could use the following binding:



<Grid Grid.Column="0" Margin="0,-19,0,22">
<CheckBox Grid.Column="0" IsChecked="{Binding Path=DataContext.IsChecked,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox},
Mode=TwoWay}" />
</Grid>



Put a breakpoint in the setter of the IsChecked property to find out if it is being set when you check and uncheck the CheckBox.


No comments:

Post a Comment