c# - wpf 中的 treeview 多重绑定(bind)

标签 c# wpf multibinding

我想将 TreeView 绑定(bind)到这样的类:

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

其他类是:

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(""));
}

如何创建显示文件和文件夹集合的 TreeView

我想用这样的东西:

 <HierarchicalDataTemplate
 DataType="{x:Type model:Folder}"
 ItemsSource="{Binding Childs}">   
 <DockPanel>
       <Label Content="{Binding Name}"/>    </DockPanel>
 </HierarchicalDataTemplate>

所以我得到了这样的东西:

根文件夹

|
|-File
|-File
|-Folder
  |-File
  |-File
  |-Folder
    |-File

最佳答案

您的问题到底是什么?如何组合它们? CompositeCollection .

编辑:如评论中所述,我的 Intuipic应用程序执行的操作与您的请求非常相似。这是一个屏幕截图:

alt text

关于c# - wpf 中的 treeview 多重绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3532924/

相关文章:

c# - (WPF/MVVM) Service 和 ViewModel 有什么区别?

.net - 抛出两次相同的异常使 WPF 崩溃

c# - WPF 多重绑定(bind)

c# - 使用 CaSTLe Windsor 进行依赖注入(inject)的多态性

c# - 从 View 模型更改Xamarin Forms应用页面

c# - 寻找发音正确性

wpf - Frame.Content、赋值操作不起作用?

c# - 使用 C++/CLI 将图片插入 Excel 并收到 100x 警告 C4691

c# - 为什么将TextBox的Value重置为先前的值而不显示错误?

wpf - ConverterParameter 与多绑定(bind)绑定(bind)