Tuesday, August 28, 2012

Set default/init Column for sorting in Silverlight

Set default/init Column for sorting in Silverlight

I found a lot of threads with the keywords above but mostly people are asking for sorting. I am asking for sorting at initialized moment. If the form loaded, the GridView should sort by a specific column already. If possible in XAML.

The default situation now, I don't need: The current loaded situation

The default situation I want to have when form is loaded: XAML default sorting in Silverlight

Any idea how to do that?

<sdk:DataGrid x:Name="dgv"                            ItemsSource="{Binding}"                            >             <sdk:DataGrid.Resources>                 <CollectionViewSource x:Key="PrioritySorter" Source="{Binding .}">                     <CollectionViewSource.SortDescriptions>                         ????? How to sort by "Active" property ASC?                     </CollectionViewSource.SortDescriptions>                 </CollectionViewSource>             </sdk:DataGrid.Resources>              <sdk:DataGrid.Columns >                 <sdk:DataGridTextColumn                              Header="N°"                              Binding="{Binding Id}"                                   IsReadOnly="True"/>              <sdk:DataGrid.Columns >                 <sdk:DataGridTextColumn                              Header="Priority"                              Binding="{Binding Priority}"  />               <sdk:DataGrid.Columns >                 <sdk:DataGridTextColumn                              Header="Active"                              Binding="{Binding Id}"  /> 

Answers & Comments...

Answer: 1

Here is the link to get the solution for what you are looking for.

Default sorting in dataGrid in Silverlight/WPF

by : vinod8812http://stackoverflow.com/users/1056509




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog