开发者

WPF Toolkit Datagrid Sorting

开发者 https://www.devze.com 2023-01-31 04:33 出处:网络
Our client has wants to sort the values in a WPF datagr开发者_如何学Pythonid. One of the columns is a time span column. However, it\'s in string format. Here are sample data.

Our client has wants to sort the values in a WPF datagr开发者_如何学Pythonid.

One of the columns is a time span column. However, it's in string format. Here are sample data.

-1 Week - Reorganize Staff

-2 Month - Design Website

-5 Years - Negotiate Merger

I've managed to turn the string data into a numeric value corresponding to the dates. I've also put that column in the datagrid. Now the client wants to sort the column with the string span. How should I go about this?


You can add property to the class

public string StringSpan { get; set; }
public TimeSpan Span { get { return ParseSomehow(StringSpan); } }

and use SortMemberPath="Span" for your DataGridColumn. So you are not obliged even to show Span in the grid.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号