How to: Display Data by Using GridViewRowPresenter
This example shows how to use the GridViewRowPresenter and GridViewHeaderRowPresenter objects to display data in columns.
Example
The following example shows how to specify a GridViewColumnCollection that displays the DayOfWeek and Year of a DateTime object by using GridViewRowPresenter and GridViewHeaderRowPresenter objects. The example also defines a Style for the Header of a GridViewColumn.
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Window.Resources>
<Style x:Key="MyHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Background" Value="BurlyWood"/>
</Style>
<GridViewColumnCollection x:Key="gvcc">
<GridViewColumn Header="Year"
DisplayMemberBinding="{Binding Year}"
Width="80"/>
<GridViewColumn Header="Day"
DisplayMemberBinding="{Binding DayOfWeek}"
Width="80" />
</GridViewColumnCollection>
</Window.Resources>
<StackPanel>
<GridViewHeaderRowPresenter Name="hrp" Columns="{StaticResource gvcc}"
ColumnHeaderContainerStyle=
"{StaticResource MyHeaderStyle}" />
<GridViewRowPresenter Columns="{StaticResource gvcc}" >
<GridViewRowPresenter.Content>
<sys:DateTime>2005/2/1</sys:DateTime>
</GridViewRowPresenter.Content>
</GridViewRowPresenter>
<GridViewRowPresenter Columns="{StaticResource gvcc}" >
<GridViewRowPresenter.Content>
<sys:DateTime>2006/10/12</sys:DateTime>
</GridViewRowPresenter.Content>
</GridViewRowPresenter>
</StackPanel>
</Window>
See also
التعاون معنا على GitHub
يمكن العثور على مصدر هذا المحتوى على GitHub حيث يمكنك أيضاً إضافة مشاكل وطلبات سحب ومراجعتها. للحصول على معلومات إضافية، اطلع على دليل المساهم لدينا.
.NET Desktop feedback
الملاحظات
https://aka.ms/ContentUserFeedback.
قريبًا: خلال عام 2024، سنتخلص تدريجيًا من GitHub Issues بوصفها آلية إرسال ملاحظات للمحتوى ونستبدلها بنظام ملاحظات جديد. لمزيد من المعلومات، راجعإرسال الملاحظات وعرضها المتعلقة بـ