I'm trying to improve ListView
. This mostly has to do with changed in the ListViewItem
class. So I inherited from both, creating two costume controls:
NestedListView : ListView
NestedListViewItem : ListViewItem
The problem is that now I want the NestedListView
's <ItemsPresenter/>
to present NestedListViewItem
s instead of regular ListViewItems
.
How do I achieve this?
(I pretty much have no idea how <ItemsPresenter/>
works. So any explanation on that area could be helpful).
Override the GetContainerForItemOverride
method and return the type of item container you want:
public class NestedListView : ListView
{
protected override DependencyObject GetContainerForItemOverride()
{
return new NestedListViewItem();
}
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is NestedListViewItem;
}
}