I want to bind a tree structure to a class like this:
public class Folder : Base_FileFolder { public Folder() { Folders = new ObservableCollection<Folder>(); Files = new ObservableCollection<File>(); } public ObservableCollection<Folder> Folders { get; set; } public ObservableCollection<File> Files { get; set; } }
other ares classes:
public class File : Base_FileFolder { } public class Base_FileFolder : DependencyObject { public string Name { get { return (string)GetValue(NameProperty); } set { SetValue(NameProperty, value); } } public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(string), typeof(Base_FileFolder), new UIPropertyMetadata("")); }
How to create a tree structure that displays a collection of files and folders
I want to use something like this:
<HierarchicalDataTemplate DataType="{x:Type model:Folder}" ItemsSource="{Binding Childs}"> <DockPanel> <Label Content="{Binding Name}"/> </DockPanel> </HierarchicalDataTemplate>
so I get Somethign as follows:
Rootfolder
| |-File |-File |-Folder |-File |-File |-Folder |-File
c # wpf multibinding
Delta
source share