Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

treeview Multibinding in wpf

I want to bind a treeview to a class like this one:

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; }
}

the other classes ares:

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 can I create a treeview that shows Files and Folders collection

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 like this:

rootFolder

|
|-File
|-File
|-Folder
  |-File
  |-File
  |-Folder
    |-File
like image 686
Delta Avatar asked Aug 20 '10 16:08

Delta


1 Answers

What exactly is your question? How to combine them? CompositeCollection.

EDIT: as mentioned in the comments, my Intuipic application does something very similar to what you're requesting. Here's a screenshot:

alt text

like image 122
Kent Boogaart Avatar answered Oct 17 '22 12:10

Kent Boogaart