开发者

Custom sort in domaincollectionview

开发者 https://www.devze.com 2023-03-22 04:40 出处:网络
I\'m using a DCV as a property in the View Model. Everything works fine but what about custom sort? Say I have a string property in my model which should be sorted alphanumerically.

I'm using a DCV as a property in the View Model. Everything works fine but what about custom sort? Say I have a string property in my model which should be sorted alphanumerically. How can I achieve such thing?

UPD:

Model:

public class MyModel
{
///...
public SomeProperty {get;set;}
}

xaml:

<data:DataTextColumn Binding={binding path=SomeProp开发者_Python百科erty}, canusersort=true />

When sorting within the datagrid, the property gets sorted with disregard to alphanumeric order, i.e. in a regular string way. I'd like to apply my custom sort, e.g. by introducing my own IComparer. No API is available at least as I know of it. Any clues?


The DomainCollectioView has special collection:

SortDescriptions

You could add next code in Your ViewModel:

DCV.SortDescriptions.Add(new SortDescription("SomeProperty ", ListSortDirection.Ascending));
0

精彩评论

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