34 lines
1.4 KiB
XML
34 lines
1.4 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"
|
|
mc:Ignorable="d"
|
|
Title="MainWindow" Height="350" Width="525">
|
|
<Grid>
|
|
|
|
<TreeView x:Name="FolderView" ItemsSource="{Binding Items}">
|
|
|
|
<TreeView.ItemContainerStyle>
|
|
<Style TargetType="{x:Type TreeViewItem}">
|
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
|
</Style>
|
|
</TreeView.ItemContainerStyle>
|
|
|
|
<TreeView.ItemTemplate>
|
|
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
|
<StackPanel Orientation="Horizontal">
|
|
<Image Width="20" Margin="3"
|
|
Source="{Binding Type,
|
|
Converter={x:Static local:HeaderToImageConverter.Instance}}" />
|
|
<TextBlock VerticalAlignment="Center" Text="{Binding Name}" />
|
|
</StackPanel>
|
|
</HierarchicalDataTemplate>
|
|
</TreeView.ItemTemplate>
|
|
|
|
</TreeView>
|
|
</Grid>
|
|
|
|
</Window>
|