Data type based data template

I have the following data type template in resource dictionary:

<DataTemplate DataType="{x:Type vm:TreeView_ViewModel}">
        <base:ucTreeLevelTreeView/>
    </DataTemplate>

(ucTreeLevelTreeView looks correct when I drop it on the window.)

I am  trying to set object of the type TreeView_ViewModel as content for HeaderedContentControl. I would expect to see ucTreeLevelTreeView  after adding  the following code to MainWindow.xaml:
<HeaderedContentControl Header="Report Selection" Content="{Binding Path=Reports}"/>

But HeaderedContentControl  is empty. There is no errors.

This is the code from MainWindowViewModel class that is set as DataContext for the form MainWindow:

public class MainWindowViewModel
    {
         TreeView_ViewModel _reportview;

        public MainWindowViewModel()
        {
            _reportview = new TreeView_ViewModel();
 
        }

        public TreeView_ViewModel Reports
        {
            get { return _reportview; }

        }
    }

This is my first WPF project, so I may not explained my problem properly. Any help would be highly appreciated.
LVL 1
crcsupportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aaron JabamaniTechnical ArchitectCommented:
Can we see the your whole xaml please.
crcsupportAuthor Commented:
This is the code for MainWindow that suppose to display custom control ucTreeLevelTreeView:
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:ReportManager.ViewModel"
        xmlns:local="clr-namespace:ReportManager" x:Name="formMainWindow" x:Class="ReportManager.MainWindow"
        Height="350" Width="525" Title="{Binding DisplayName}" WindowStartupLocation="CenterScreen" >
    <Window.Resources>
        <ResourceDictionary Source="Resources\MainResource.xaml"/>
    </Window.Resources>
    <DockPanel>
        <DockPanel DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="None" Margin="0,0,0,0" Height="22" VerticalAlignment="Top">
            <Menu Height="22" VerticalAlignment="Top" KeyboardNavigation.TabNavigation="Cycle">
                <MenuItem Header="_Rights" />
                <MenuItem Header="_Help" />
                <MenuItem Header="E_xit" Command="{Binding CloseCommand}" />
            </Menu>
        </DockPanel>
        <Grid Margin="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="130" />
                <ColumnDefinition Width="6"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Border BorderBrush="Black" BorderThickness="1" Margin="0" >
                <HeaderedContentControl Header="Report Selection"
                              x:Name="TreeViewContainer"
                    Content="{Binding Path=Reports}"/>
            </Border>

This is the custom control ( 3-level TreeView):

<UserControl x:Class="ReportManager.ucTreeLevelTreeView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:ReportManager.ViewModel"
             xmlns:base="clr-namespace:ReportManager.GeneralClasses"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
     
        <DataTemplate x:Key="report">
            <TextBlock Text="{Binding Path=Name}" />
        </DataTemplate>
       
        <HierarchicalDataTemplate x:Key="subsection"
                                  ItemsSource="{Binding ManagedNodes}"
                                  ItemTemplate="{StaticResource report}">
            <TextBlock Text="{Binding Path=Name}" />
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="section"
                                  ItemsSource="{Binding NodeList}"
                                  ItemTemplate="{StaticResource subsection}">
            <TextBlock Text="{Binding Path=NodeName}" />
        </HierarchicalDataTemplate>

    </UserControl.Resources>
   
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
         </Grid.RowDefinitions>
        <TreeView Grid.Row="1"
                      ItemTemplate="{StaticResource section}"
                      ItemsSource="{Binding Path=Reports}"
                      SelectedValuePath="{Binding Path=Name}"
                 
                      Name="tvReports" />
    </Grid>
</UserControl>

            <GridSplitter Grid.Row="0" Grid.Column="1" Margin="2,0,2,0"
                        Width="5" Background="LightBlue" VerticalAlignment="Stretch" HorizontalAlignment="Center" />

        </Grid>
    </DockPanel>
</Window>
crcsupportAuthor Commented:
I found work around

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crcsupportAuthor Commented:
found work around
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.