WPF Toolkit datagrid column header checkbox access

Oct 15, 2009 at 10:01 AM

Hi,

I am having a checkbox in my datagrid column header to select or deselect all the rows by checking the checkbox. Now the issue is I want to check or uncheck that column header checkbox programmatically through code. How can we achieve this? Expecting a reply :(

My code snippet is as follows:

<dg:DataGrid Margin="238,107,10,0" Background="Transparent" SelectionMode="Single" SelectionUnit="FullRow" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" CanUserSortColumns="False" ItemsSource="{Binding Path=.}" Name="ShutdownTasksDataGrid" Visibility="Visible" Height="210" VerticalAlignment="Top" IsReadOnly="True" PreviewKeyDown="ShutdownTasksDataGrid_PreviewKeyDown">

<dg:DataGrid.BitmapEffect>

 

<font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<OuterGlowBitmapEffect GlowColor="SteelBlue" /> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

</dg:DataGrid.BitmapEffect> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<dg:DataGrid.Columns> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<dg:DataGridTemplateColumn x:Name="IsCompleted" IsReadOnly="False" Visibility="Visible"> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<dg:DataGridTemplateColumn.HeaderTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<DataTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<CheckBox x:Name="HeaderCheckBox" Content="{Binding}" IsChecked="False" IsThreeState="False" Click="HeaderCheckBox_Click"/> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

</DataTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

</dg:DataGridTemplateColumn.HeaderTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<dg:DataGridTemplateColumn.CellTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<DataTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

<CheckBox HorizontalContentAlignment="Center" IsChecked="{Binding Path=Complete}" IsThreeState="False" Name="Complete" VerticalContentAlignment="Center" Checked="Complete_Checked" Unchecked="Complete_Unchecked"/> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

</DataTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

</dg:DataGridTemplateColumn.CellTemplate> <font size="2" color="#a31515"><font size="2" color="#a31515">

 

</font></font><font size="2" color="#a31515">

 

</font>

</dg:DataGridTemplateColumn>

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

</

</font></font><font size="2" color="#0000ff">

 

</font>

dg:DataGrid.Columns> <font size="2" color="#a31515"><font size="2" color="#a31515">

 <

</font></font><font size="2" color="#a31515">

 

</font>

/dg:DataGrid>

Now I want to access the "HeaderCheckBox" in my code. How can we accomplish this?

 

Thanks and Regards,

Subalakshmi Vijayarajan.