<ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding Path={x:Static vmc:clsPersonViewModel.ChildrenPath}, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vmc:clsPersonViewModel}">
<TextBlock Text="{Binding Path={x:Static vmc:clsPersonViewModel.TrimPath}}"
Height="20"
Margin="2">
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
In the code above, if there are no children (the ChildrenPath property returns NULL), nothing is rendered in the view. In the code below, when ChildrenDataSetPath is NULL the XamDataGrid still gets rendered. How do I achieve the same for a single object (as opposed to a collection) as the datacontext?
<DataTemplate DataType="{x:Type vmb:clsPersonViewModel}">
<igDP:XamDataGrid DataSource="{Binding Path={x:Static vmb:clsPersonViewModel.ChildrenDataSetPath}}">
</igDP:XamDataGrid>
</DataTemplate>
I finally achieved this by using ContentControl. I mapped my DataContext to Content property of ContentControl and then added Datat Template for the view in resources. When the datacontext is not of type clsPersonViewModel, it does not show the ucPersonView.