jeudi 29 janvier 2015

How do I write code to select/unselect all checkbox on selecting checkbox header of data grid WPF?

This question may seem very old but I am not able to solve myself.


I am new to WPF.


I am facing little issues on working with data grid in WPF. Previously I was comfortable with Windows forms.


I have added a checkbox column in data grid and added a checkbox in the header.


Now How do I write code to select/unselect all checkbox on selecting checkbox header?


I tried all the possible answers from other posts but I am unable to success on it. I am little confused somewhere.



<DataGrid AutoGenerateColumns="True" Height="204" HorizontalAlignment="Left" Margin="38,162,0,48" Name="dataGrid1" VerticalAlignment="Stretch" Width="729" AreRowDetailsFrozen="False" EnableColumnVirtualization="False" IsManipulationEnabled="False" CanUserAddRows="False" AutoGeneratingColumn="dataGrid1_AutoGeneratingColumn" RowHeight="26" ColumnHeaderHeight="26" FontSize="15">
<DataGrid.Columns>
<DataGridCheckBoxColumn >
<DataGridCheckBoxColumn.Header>
<CheckBox Name="SelectAll" ></CheckBox>
</DataGridCheckBoxColumn.Header>
</DataGridCheckBoxColumn>
</DataGrid.Columns>
</DataGrid>


What should I do next?





Aucun commentaire:

Enregistrer un commentaire