views:

180

answers:

1

I have ItemsControl in a WPF application, which is bind to an array of objects. And I am using ItemTemplate to render the list. I want to display for each item in the list the item order, like for example

Customer 1 Name : xxxxx Age: 9999

Customer 2 Name : yyyy Age: 8888

Any idea how to do it Thanks

+2  A: 

I think what you are asking is how to sort your ItemsSource property when displaying it in an items control?

You can do this by using a CollectionViewSource. The CollectionViewSource gives you the ability group and / or sort your ItemsSource. It does this by creating a "view" which is a separate copy of your items source with your grouping and sorting applied to it.

This allows you to show your data in multiple different groupings or sortings on the same page while still only having one underlying source collection.

Foovanadil
Any explanation for the down vote?
Foovanadil
Your answer is spot on... It wouldn't be the OP himself doing this? It happened to a correct answer on his other question as well...
Dabblernl
@Foovanadil, I agree with you, sometimes kids just put down vote because they can and they like, and no one asks for any explanation. I think comment on downvote should be compulsory.
Akash Kava
Totally agree. I think if you are going to down vote something you should explain yourself. I know I do if I down vote something
Foovanadil