I have a simple datagrid which can be sorted by开发者_如何学JAVA clicking the column header. When I open the window, datagrid is not sorted. Then, when I click, arrow appears and it's sorted asc, click again - sorted desc etc. very simple.
What I need to do, is to open window with already sorted datagrid. So arrows (that shows which direction datagrid is sorted) should be always visible. I have to have my datagrid sorted all the time. How can I do that? I prefer to do that in xaml, but any solution will be great.
BTW. App in .NET4
You can set your sort on the column itself
<DataGrid>
    <DataGrid.Columns>
        <DataGridTextColumn SortMemberPath="Name" SortDirection="Descending" />
    </DataGrid.Columns>
</DataGrid>
it depends on the design of your grid, you can do this in XAML directly, for example having an entry like this:
<Trigger Property="SortDirection" Value="Ascending">
check this page:
Styling Microsoft’s WPF datagrid
DataGridColumn.SortDirection. This property gets or sets direction of the sorting.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论