Emir Ahmetović
Emir Ahmetović

Reputation: 63

How to get Items from ItemsSource?

I am using a custom control that has an ItemsSource. I have bound the ItemsSource to a CollectionViewSource in XAML. That CollectionViewSource is bound to a List.

Now I want to get all the Items from the ItemsSource but that control doesn't have a property Items (like GridView or ListView has). So I have to manually get the items from the ItemsSource.

The ItemsSource is an object, but when I put a breakpoint to check what value is stored in the ItemsSource i get this: Windows Runtime Object. So my question again: How to get the Items from this ItemsSource?

Upvotes: 0

Views: 2488

Answers (1)

Emir Ahmetović
Emir Ahmetović

Reputation: 63

I got the solution:

valueList = (myControl.ItemsSource as ICollectionView).ToList();

Upvotes: 3

Related Questions