I have my own treeview implementation based on this post, but I have problems defining a different style based on what object type is in the treeviewitem. I know the simple way is to define a templateselector, but I can't figure out how this would work when you have two HierarchicalDataTemplates.
<HierarchicalDataTemplate DataType="{x:Type domainLayer:Folder}" ItemsSource="{Binding Converter={StaticResource BaseTypeConverter}}" />
<HierarchicalDataTemplate DataType="{x:Type domainLayer:Document}" ItemsSource="{Binding Converter={StaticResource BaseTypeConverter}}" />
I use these templates to lazy load my tree, which works fine. There's also a Style defined for all TreeListViewItems. Maybe there's a solution too, but I can't figure out how to define if my TreeListViewItem is either a Folder or a Document.
Any help is much appreciated. If you need more code, just let me know!
Update 10:40am:
In a Style the row is defined for every TreeListViewItem:
<Style x:Key="cxc" TargetType="{x:Type local:TreeListViewItem}">
<Setter Property="FontFamily" Value="TradeGothic LT" />
<Setter Property="FontSize" Value="14px" />
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
<Setter Property="Background" Value="Transparent" />
<EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:TreeListViewItem}">
<StackPanel>
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<GridViewRowPresenter x:Name="PART_Header"
Content="{TemplateBinding Header}"
Columns="{Binding Path=Columns,RelativeSource={RelativeSource AncestorType={x:Type local:TreeListView}}}"
/>
</Border>
<ItemsPresenter x:Name="ItemsHost" />
</StackPanel>
<ControlTemplate.Triggers>
<!-- ... -->
When I copy the template (everything in the StackPanel tag) to the HierarchicalDataTemplate I get an error: Cannot find the static member 'BackgroundProperty' on the type 'ContentPresenter'.