-
Notifications
You must be signed in to change notification settings - Fork 4
/
FolderPickerControl.xaml
37 lines (37 loc) · 2.02 KB
/
FolderPickerControl.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<UserControl x:Class="FolderPickerLib.FolderPickerControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FolderPickerLib"
mc:Ignorable="d"
x:Name="pickerControl"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<local:DriveIconConverter x:Key="DriveIconConverter"/>
<ContextMenu x:Key="TreeItemContextMenu">
<MenuItem Header="Create" Click="CreateMenuItem_Click"/>
<MenuItem Header="Rename" Click="RenameMenuItem_Click"/>
<MenuItem Header="Delete" Click="DeleteMenuItem_Click"/>
</ContextMenu>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TreeView x:Name="TreeView"
ItemsSource="{Binding ElementName=pickerControl,Path=Root.Childs}"
ItemContainerStyle="{Binding ElementName=pickerControl,Path=ItemContainerStyle}"
TreeViewItem.Expanded="TreeView_Expanded" TreeViewItem.Selected="TreeView_Selected">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource ="{Binding Childs}">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource TreeItemContextMenu}">
<Image Height="16" Width="16" Source="{Binding Converter={StaticResource DriveIconConverter}}"/>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
</UserControl>