Dave Burke : Freelance .NET Web Developer specializing in Online Communities

Silverlite: Why datagrid column sorting might not be working

Column sorting in my recent Silverlight 2.0 Datagrid app wasn't a priority, but I wanted to be able to click on a column header and sort, darn it.  I added a CanUserSortColumns="true" property to the DataGrid and CanUserSort="true" to each DataGridTemplateColumn.  Still nothing.

It wasn't until I added a SortMemberPath property to the DataGridTemplateColumn some days later that I could enjoy that sexy Silverlight 2.0 Datagrid column sorting. 


<data:DataGridTemplateColumn Header="Employee" Width="200" CanUserSort="True"
  
SortMemberPath="EmployeeName">
    <data:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding EmployeeName}" />
    </DataTemplate>
    .....

Comments (2) | Post RSS RSS comment feed

Posted on 11/9/2008 3:20:13 PM by Dave Burke
Categories: .NET | Silverlight
Tags: no tags for this post

Related posts

Comments (2) -

11/12/2008 3:09:20 PM Permalink

Thank you !

After you indicate this I took a look in MSDN and I found the explanation:

"In columns that are derived from DataGridBoundColumn, such as DataGridTextColumn and DataGridCheckBoxColumn, the SortMemberPath is set to the property that the column is bound to through the Binding property by default. In columns that are derived from DataGridColumn, such as DataGridTemplateColumn, the SortMemberPath property must be set to enable automatic sorting of the column. "

Me United States |

11/12/2008 4:56:22 PM Permalink

Thank YOU, Me, for the explanation.  I often don't get that far... Smile

Dave Burke United States |

Pingbacks and trackbacks (3)+


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke