I'm trying bind my Classes to HierarchicalDataTemplate. See code below.
XAML
<Window x:Name="window" x:Class="MyCompany.Press.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:helpers="clr-namespace:MyCompany.Press.Helpers"
xmlns:press="clr-namespace:MyCompany.Press"
mc:Ignorable="d"
Title="Press analyzer" Height="500" Width="800.5" ContentRendered="WindowContentRenderedEventHendler" Closing="WindowClosingEventHandler"
d:DataContext="{d:DesignData MainWindow}">
<Grid Name="MainGrid">
...
<TreeView Name="ArticlesTreeView" Grid.Column="0" AllowDrop="True" >
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type press:NewsPaperDocument}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" FontWeight="Bold" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type press:NewsPaperPage}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" Foreground="#00a300" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type press:NewsPaperTitle}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" Foreground="#da532c" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type press:NewsPaperBlock}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" Foreground="#2b5797" />
</DataTemplate>
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<!-- Style for the selected item -->
<Setter Property="BorderThickness" Value="1" />
<Style.Triggers>
<!-- Selected and has focus -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="#7DA2CE" />
</Trigger>
<!-- Mouse over -->
<Trigger Property="helpers:TreeViewHelper.IsMouseDirectlyOverItem" Value="True">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFAFBFD" Offset="0" />
<GradientStop Color="#FFEBF3FD" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="#B8D6FB" />
</Trigger>
<!-- Selected but does not have the focus -->
...
</Style.Triggers>
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="2" />
</Style>
</Style.Resources>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</Grid>
</Grid>
</Window>
If I use x:Type, designer say
Design view is unavailable for x64 and ARM target platforms.
and error like
The name "NewsPaperDocument" does not exist in the namespace "clr-namespace:MyCompany.Press"
but code compile and run completely.
Same error I have on <Trigger Property="helpers:TreeViewHelper.IsMouseDirectlyOverItem" Value="True"> line.
If I remove x:Type designer works fine, but HierarchicalDataTemplate doesn't work correctly
P.S. TreeViewHelper I get here http://blogs.msdn.com/b/mikehillberg/archive/2006/09/21/mytreeviewhelperismousedirectlyoveritem.aspx