点击查看代码
<Window.Resources>
<Style x:Key="MyHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Background" Value="BurlyWood" />
</Style>
<GridViewColumnCollection x:Key="gvcc">
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding Year}"
Header="Year" />
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding DayOfWeek}"
Header="Day" />
</GridViewColumnCollection>
</Window.Resources>
<StackPanel>
<GridViewHeaderRowPresenter Name="hrp"
ColumnHeaderContainerStyle="{StaticResource MyHeaderStyle}"
Columns="{StaticResource gvcc}" />
<GridViewRowPresenter Columns="{StaticResource gvcc}">
<GridViewRowPresenter.Content>
<sys:DateTime>2005/2/1</sys:DateTime>
</GridViewRowPresenter.Content>
</GridViewRowPresenter>
<GridViewRowPresenter Columns="{StaticResource gvcc}">
<GridViewRowPresenter.Content>
<sys:DateTime>2024/11/17</sys:DateTime>
</GridViewRowPresenter.Content>
</GridViewRowPresenter>
<GridViewRowPresenter Columns="{StaticResource gvcc}">
<GridViewRowPresenter.Content>
<sys:DateTime>2024/11/17</sys:DateTime>
</GridViewRowPresenter.Content>
</GridViewRowPresenter>
</StackPanel>
GridViewHeaderRowPresenter:
表格标题行呈现器
ColumnHeaderContainerStyle:
列的Style
GridViewColumnCollection : ->Columns
布局视图列的集合
GridViewRowPresenter:
表格行呈现器
![(/i/l/?n=24&i=blog/3364307/202411/3364307-20241119154223981-816311491.png)]