35 lines
1.6 KiB
XML
35 lines
1.6 KiB
XML
<Window x:Class="WpfTreeView.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:local="clr-namespace:WpfTreeView"
|
|
Loaded="Window_Loaded"
|
|
mc:Ignorable="d"
|
|
Title="MainWindow" Height="350" Width="525">
|
|
<Grid>
|
|
|
|
<TreeView x:Name="FolderView">
|
|
<TreeView.Resources>
|
|
|
|
<Style TargetType="{x:Type TreeViewItem}">
|
|
<Setter Property="HeaderTemplate">
|
|
<Setter.Value>
|
|
<DataTemplate>
|
|
<StackPanel Orientation="Horizontal">
|
|
<Image Width="20" Margin="3"
|
|
Source="{Binding
|
|
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TreeViewItem}},
|
|
Path=Tag,
|
|
Converter={x:Static local:HeaderToImageConverter.Instance}}" />
|
|
<TextBlock VerticalAlignment="Center" Text="{Binding}" />
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</TreeView.Resources>
|
|
</TreeView>
|
|
</Grid>
|
|
</Window>
|