1

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.

Harsh
  • 3,683
  • 2
  • 25
  • 41

2 Answers2

1

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.

ecMode
  • 530
  • 3
  • 16
  • Thanks, this link helped me with the example. http://stackoverflow.com/questions/6789236/how-does-wpf-inotifypropertychanged-work Thanks for the idea. – Harsh Jul 11 '12 at 11:50
0

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;
Tod
  • 8,192
  • 5
  • 52
  • 93