I created a custom control that contains a ListView with a custom item ItemsPanelTemplate.
<UserControl x:Class="..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="thisUserControl">
<ListView ItemsSource="{Binding Source={StaticResource cvs}}"
Name="mainListView">
<ListView.GroupStyle>
<GroupStyle>
...
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<cd:TimeLinePanel UnitsPerSecond="{Binding ElementName=thisUserControl,Path=DataContext.UnitsPerSecond}" Start="{Binding ElementName=thisUserControl, Path=DataContext.Start}"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
The DataContext UserControl has two properties, Start and UnitsPerSecond. Since I use groups, I can't just write
Start={Binding Path=.Start}
So I used the code above. But if I changed the start binding to this, I get an exception:
VisualTree of ItemsPanelTemplate must be a single item.
Obviously, an ItemPanelTemplate has only one item.
So what could be the problem? My user panel does not create any elements. He just suits them.
source
share