[Unity] Using a custom type in ItemCollection
Posted: 06 Aug 2014, 16:41
I have XAML containing an ItemsControl. I wish to fill the Items property of this ItemsControl with objects of a custom type, like so:
This fails, because Add() needs a BaseComponent, and Foo is not a basecomponent. Is there any way to deal with this or can I only use built in types in this manner?
Code: Select all
var itemsControl = FindName<ItemsControl>("MyItemsControl");
var itemCollection = itemsControl.GetItems();
foreach (Foo item in myFooItems)
{
itemCollection.Add(item);
}