mercredi 22 mars 2017

How to bind CheckBox IsChecked to ListBox of CheckBoxes

I have a list of check boxes and a single check box that acts as CheckAll/UncheckAll for all items in the listbox.

How can I make the chkAll Check Box checked if all the items are checked in the listbox binding ?

I could create a property in the view model to achieve that. I would like to do it in the xaml code.

 <ListBox Name="listBox" ItemsSource="{Binding mySource}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding IsSelectedProperty}">
                        </CheckBox>
                    </DataTemplate>
                </ListBox.ItemTemplate>
  </ListBox>


<CheckBox Name="chkAll" Content="CheckAll/UnCheckAll" IsChecked ={}/>




Aucun commentaire:

Enregistrer un commentaire