设置数据网格右上角标题单元格的样式 [英] Styling the upper right corner header cell of a datagrid
本文介绍了设置数据网格右上角标题单元格的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何更改数据网格右上角单元格的样式和内容,即所有列标题和所有行标题上方的空间?我已经看到了用于样式化列标题和行标题的示例,但是该单元格似乎 两者都不是.
How do I change the style and content of the upper right corner cell of the datagrid, i.e. the space that is left to all column headers and above all row headers? I have seen examples for styling the column headers and the row headers, but that cell seems to be neither of the two.
我最终要实现的目标是在其中放置一个复选框,以允许全选/不选.
What I am ultimately trying to achieve is putting a checkbox there to allow for select all/none.
任何帮助表示赞赏.
J .-
推荐答案
J.
您可以使用行标题团队面板在数据网格的最左侧添加一个复选框列.
You can use row header teamplate to add a checkbox column to the left most of the datagrid.
以下是这样做的XAML示例:
Following is the XAML sample of doing that:
<DataGrid AutoGenerateColumns="True" Height="200" HorizontalAlignment="Left" Margin="10,10,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="200" PreviewMouseLeftButtonUp="DataGrid_PreviewMouseLeftButtonUp" PreviewMouseLeftButtonDown="DataGrid_PreviewMouseLeftButtonDown">
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<Grid>
<CheckBox IsChecked="{Binding Path=IsSelected,Mode=TwoWay,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type DataGridRow}}}" />
</Grid>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
</DataGrid>
这篇关于设置数据网格右上角标题单元格的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文