-
I have hierarchy of view models: class MainViewModel
{
ObservableCollection<NetworkViewModel> Networks { get; }
}
class NetworkViewModel
{
ObservableCollection<NodeViewModel> Nodes { get; }
} I need to display list of Networks and list of Nodes inside each Network. <Window.Resources>
<DataTemplate x:Key="NodesDataTemplate">
<TabControl Name="PART_NodesTabControl" ItemsSource="{Binding Nodes}"/>
</DataTemplate>
</Window.Resources>
<ContentControl Name="NetworksView" Content="{Binding Networks}">
<ContentControl.ContentTemplate>
<vm:NetworksTemplateSelector>
<DataTemplate x:Key="SingleNetworkTemplate">
<ItemsControl ItemsSource="{Binding}" ItemTemplate="{StaticResource NodesDataTemplate}"/>
</DataTemplate>
<DataTemplate x:Key="MultipleNetworksTemplate">
<TabControl ItemsSource="{Binding}" ContentTemplate="{StaticResource NodesDataTemplate}"/>
</DataTemplate>
</vm:NetworksTemplateSelector>
</ContentControl.ContentTemplate>
</ContentControl> The creation of view models and assignment of DataContext are performed in the window constructor (after InitializeComponent). At this point, the list of networks and nodes in them already exists. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Why not simply hide the TabHeader if Count is 1? You may need to copy the ControlTemplate to do so probably |
Beta Was this translation helpful? Give feedback.
Why not simply hide the TabHeader if Count is 1? You may need to copy the ControlTemplate to do so probably