vue-java-tutorials/CSharp/WPFTutorial/WPF-25-TreeView/MainWindow.xaml

32 lines
1.6 KiB
XML

<Window x:Class="WPF_25_TreeView.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:WPF_25_TreeView.Convert"
mc:Ignorable="d" Loaded="MainWindow_OnLoaded"
WindowStartupLocation="CenterScreen"
Title="MainWindow1" Height="450" Width="800">
<Grid>
<TreeView Name="FolderView">
<TreeView.Resources>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Width="20" Height="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>