WPF datagrid排序方向

时间:2009-11-24 14:27:45

标签: wpf sorting datagrid wpfdatagrid

如何查看排序按钮&我DataGrid中每列的方向?

或者甚至更好,如何在列标题之间看到分隔符?

这是我的网格代码:

<Window.Resources>
  <Style x:Key="HeaderTextStyle"
         TargetType="{x:Type dg:DataGridColumnHeader}">
    <Setter Property="Background"
            Value="DarkSlateGray" />
    <Setter Property="Foreground"
            Value="White" />
  </Style>
</Window.Resources>

<dg:DataGrid CanUserAddRows="false"
             RowHeaderWidth="0"
             x:Name="movieGrid"
             Background="DarkSlateGray"
             ItemsSource="{Binding ElementName=This, Path=GameData}"
             ColumnWidth="*"
             Margin="5,35,5,5"
             AutoGenerateColumns="False"
             ColumnHeaderStyle="{StaticResource HeaderTextStyle}"
             BeginningEdit="DataGrid_BeginningEdit"
             CanUserResizeRows="False"
             CanUserResizeColumns="False">
  <dg:DataGrid.Columns>
    <dg:DataGridTextColumn IsReadOnly="True"
                           Binding="{Binding Title}"
                           Header="Title" />
    <dg:DataGridTextColumn IsReadOnly="True"
                           Width="60"
                           Binding="{Binding Score}"
                           Header="Score" />
    <dg:DataGridTextColumn IsReadOnly="True"
                           Width="60"
                           Binding="{Binding Year}"
                           Header="Year" />
    <dg:DataGridTextColumn IsReadOnly="True"
                           Binding="{Binding Genre}"
                           Header="Genre" />
    <dg:DataGridTemplateColumn Width="195"
                               Header="Link">
      <dg:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <TextBlock Margin="3,0,0,0">
            <Hyperlink Tag="{Binding Link}"
                       Click="Link_Click">
              <TextBlock Text="{Binding Link}" />
            </Hyperlink>
          </TextBlock>
        </DataTemplate>
      </dg:DataGridTemplateColumn.CellTemplate>
    </dg:DataGridTemplateColumn>
    <dg:DataGridCheckBoxColumn Width="50"
                               Binding="{Binding Seen}"
                               Header="Seen" />
  </dg:DataGrid.Columns>
</dg:DataGrid>

非常感谢!

1 个答案:

答案 0 :(得分:0)

有一个很好的例子herehereGoogle says