Created
February 27, 2012 21:51
-
-
Save jsonw23/1927340 to your computer and use it in GitHub Desktop.
Folder Tree WPF Control: Part 1 - Factored out Data Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UserControl x:Class="GeekJ.FolderTreeControl.FolderTree" | |
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:model="clr-namespace:GeekJ.FolderTreeControl.Model" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
mc:Ignorable="d" | |
d:DesignHeight="300" d:DesignWidth="300" | |
Loaded="FolderTree_Loaded" DataContextChanged="FolderTree_DataContextChanged"> | |
<UserControl.Resources> | |
<HierarchicalDataTemplate DataType="{x:Type model:Drive}" ItemsSource="{Binding Path=Folders}"> | |
<TextBlock Text="{Binding Path=Label}"/> | |
</HierarchicalDataTemplate> | |
<HierarchicalDataTemplate DataType="{x:Type model:Folder}" ItemsSource="{Binding Path=Folders}"> | |
<TextBlock Text="{Binding Path=Label}"/> | |
</HierarchicalDataTemplate> | |
</UserControl.Resources> | |
<Grid> | |
<TreeView ItemsSource="{Binding Path=Drives}" TreeViewItem.Expanded="FolderTree_Expanded"> | |
<TreeView.ItemContainerStyle> | |
<Style TargetType="TreeViewItem"> | |
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" /> | |
</Style> | |
</TreeView.ItemContainerStyle> | |
</TreeView> | |
</Grid> | |
</UserControl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment