SHARE
TWEET

Untitled

a guest Jun 16th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <DataTemplate x:Key="FolderTemplate" x:DataType="localdata:FolderInfo">
  2.         <TreeViewItem ItemsSource="{x:Bind subFolders}">
  3.             <StackPanel Orientation="Horizontal">
  4.                 <TextBlock Text="#Folder#" />
  5.                 <Image Width="20" Source="Assets/img2.png"/>
  6.                 <TextBlock Text="{x:Bind  FolderName }" />
  7.             </StackPanel>
  8.         </TreeViewItem>
  9.     </DataTemplate>
  10.  
  11.     <DataTemplate x:Key="FileTemplate" x:DataType="localdata:FolderInfo">
  12.         <TreeViewItem>
  13.             <StackPanel Orientation="Horizontal">
  14.                 <Image Width="20" Source="Assets/img3.png"/>
  15.                 <TextBlock Text="{x:Bind FolderName}"/>
  16.             </StackPanel>
  17.         </TreeViewItem>
  18.     </DataTemplate>
  19.  
  20.  
  21.     <localdata:ExplorerItemTemplateSelector
  22.         x:Key="ExplorerItemTemplateSelector"
  23.         FolderTemplate="{StaticResource FolderTemplate}"
  24.         FileTemplate="{StaticResource FileTemplate}" />
  25.      
  26. <TreeView  
  27.         x:Name="treeview" Grid.Row="2" ItemsSource="{Binding storageFolders,Mode=OneWay}"
  28.         Style="{StaticResource TreeViewStyle1}"
  29.  
  30.         >
  31.             <TreeView.ItemTemplate>
  32.                 <DataTemplate x:DataType="localdata:FolderInfo">
  33.                     <TreeViewItem ItemsSource="{x:Bind subFolders}" Content="{x:Bind FolderName}"/>
  34.                 </DataTemplate>
  35.             </TreeView.ItemTemplate>
  36.         </TreeView>
  37.      
  38. public class ExplorerItemTemplateSelector : DataTemplateSelector
  39. {
  40.     public DataTemplate FolderTemplate { get; set; }
  41.     public DataTemplate FileTemplate { get; set; }
  42.  
  43.     protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
  44.     {
  45.         var explorerItem = (FolderInfo)item;
  46.         if (explorerItem.IsFolder == true) return FolderTemplate;
  47.  
  48.         return FileTemplate;
  49.     }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top