Reputation: 3751
I have a datagrid with a combobox in the header. I am using the combobox to select an deseclect all the values in the column. Here is the xaml code for it:
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<CheckBox x:Name="chbSelectAll" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Padding="0"
Checked="chbSelectAll_Checked" Unchecked="chbSelectAll_Unchecked" IsChecked="False"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
I can now set the column values by using the checked/unchecked event. Now I want to access the value of the checkbox in the header. Or simply a way to uncheck it through code.
Upvotes: 1
Views: 248
Reputation: 8242
It looks like you're not using MVVM, so if you're not adverse to using the code behind you can just reference the check box by the name your gave it.
chbSelectAll.IsChecked = true;
Upvotes: 0
Reputation: 540
You can implement an inotifypropertychanged property to bind to with your checkbox's "ischecked" property. This would allow to access the value as well as set it within your viewmodel.
Upvotes: 1