C# WPF treeview添加到列表框
我正在做一个小的WPF项目,需要将treeview节点添加到listbox,目前我有绑定数据到我的treeview:C# WPF treeview添加到列表框,c#,wpf,xaml,listbox,treeview,C#,Wpf,Xaml,Listbox,Treeview,我正在做一个小的WPF项目,需要将treeview节点添加到listbox,目前我有绑定数据到我的treeview: <Window.Resources> <HierarchicalDataTemplate DataType="{x:Type data:Category}" ItemsSource="{Binding Path=Products}"> <TextBlock Text="{Binding Path=CategoryNam
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type data:Category}" ItemsSource="{Binding Path=Products}">
<TextBlock Text="{Binding Path=CategoryName}" AllowDrop="True"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type data:Product}" >
<TextBlock Text="{Binding Path=ModelName}" AllowDrop="True"/>
</HierarchicalDataTemplate>
</Window.Resources>
<TreeView x:Name="tv_Project" Margin="5" />
但是我不知道如何编写将treeview节点添加到listbox的代码,通常应用程序会单击:右键单击treeview节点将其添加到listbox(或直接将treeview节点拖动到listbox),希望我能清楚地解释我的问题,谢谢 类别和产品是否有不同的列表框,或者使用相同的列表框?只有一个列表框可以有一个列表框来显示字符串列表。这些字符串可以是类别和模型的名称。现在,在树视图节点上添加上下文菜单。单击鼠标右键,关联菜单将打开,您可以向列表框添加类别或模型。单击上下文菜单,将所选项目添加到列表框项目源。
tv_Project.ItemsSource = App.StoreDb.GetCategoriesAndProducts();