DataGrid 使用模型列后实现点击列名称排序
代码如下:
<DataGridTemplateColumn Header="型 号" SortMemberPath="OrderID.Description" CanUserSort="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox IsReadOnly="True" Text="{Binding OrderID.Description}" BorderThickness="0,0,0,0"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="序列号" SortMemberPath="SN" CanUserSort="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox IsReadOnly="True" Text="{Binding SN}" BorderThickness="0,0,0,0"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
实现字段 : SortMemberPath="OrderID.Description" CanUserSort="True"