Cannot sort Silverlight DataGrid time column
I have run into one problem while working on Silverlight DataGrid sorting functionnality. There was a problem of sorting DateTime column.
In order to enable sorting for ordinary columns in Silverlight DataGrid control all you have to do is simply add
to the definition of the column
In order to enable sorting for ordinary columns in Silverlight DataGrid control all you have to do is simply add
CanUserSort="True
to the definition of the column
<sdk:DataGridTemplateColumn x:Name="timeColumn" Header="Time" Width="Auto" CanUserSort="True" >
This works perfectly for ordinary fields(like integers). But for the DateTime type it does not work. And solution for this is to add jet another parameter
SortMemberPath="Time" >
And now this works!
<sdk:DataGridTemplateColumn x:Name="timeColumn" Header="Time" Width="Auto" CanUserSort="True" SortMemberPath="Time" ><sdk:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <sdk:DatePicker SelectedDate="{Binding Path=Time, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" /> DataTemplate> sdk:DataGridTemplateColumn.CellEditingTemplate> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Time, StringFormat=\{0:d\}}" /> DataTemplate> sdk:DataGridTemplateColumn.CellTemplate> sdk:DataGridTemplateColumn>
Comments
Post a Comment