Handy Control DataGrid 全选
Posted 喜爱糖葫芦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Handy Control DataGrid 全选相关的知识,希望对你有一定的参考价值。
提问
如何实现Handy Control DataGrid 全选
回答
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
if (((sender as CheckBox)!).IsChecked!.Value)
foreach (var item in ((grid1.DataContext as TrendDataSyncDialogViewModel)!).TrendTagCollection)
item.IsSelected = true;
else
foreach (var item in ((grid1.DataContext as TrendDataSyncDialogViewModel)!).TrendTagCollection)
item.IsSelected = false;
<DataGrid Name="grid1" Grid.Row="1" hc:DataGridAttach.ShowRowNumber="True" hc:DataGridAttach.CanUnselectAllWithBlankArea="True" HeadersVisibility="All" RowHeaderWidth="60" AutoGenerateColumns="False" ItemsSource="Binding TrendTagCollection">
<DataGrid.Columns>
<DataGridCheckBoxColumn Width="80" CanUserResize="False" Binding="Binding IsSelected" >
<DataGridColumn.Header >
<CheckBox Name="CheckAll" Content="全选" Unchecked="ButtonBase_OnClick" Checked="ButtonBase_OnClick" ></CheckBox>
</DataGridColumn.Header>
</DataGridCheckBoxColumn>
<DataGridTextColumn IsReadOnly="True" Width="180" CanUserResize="False" Binding="Binding xxx" Header="xxx"/>
<DataGridTextColumn IsReadOnly="True" Width="*" CanUserResize="False" Binding="Binding xxx" Header="xxx"/>
<DataGridTextColumn IsReadOnly="True" Width="80" CanUserResize="False" Binding="Binding xxx" Header="xxx"/>
<DataGridTextColumn IsReadOnly="True" Width="80" CanUserResize="False" Binding="Binding xxx" Header="xxx"/>
</DataGrid.Columns>
</DataGrid>
以上是关于Handy Control DataGrid 全选的主要内容,如果未能解决你的问题,请参考以下文章
wpf datagrid 一列下拉多选comboBox怎么实现??
使用easyui datagrid 的多选,但不能全选怎么回事?