我正在尝试在 wpf 中以未绑定模式 devexpress 控件构建树。我参考了以下链接Building a Tree in Unbound Mode。请检查图像,我在 xaml 代码中遇到错误。所需的输出是硬编码数据必须出现在树列表中,但如果我从第 38-44 行删除 xaml 代码,则出现的输出只是一个树结构。我知道错误出现在 xaml 中,我仍然提供 cs 代码。
***************************代码********************** *******************
namespace PstImporter
{
/// <summary>
/// Interaction logic for pstSelect.xaml
/// </summary>
public partial class pstSelect : Window
{
string stgPath;
public pstSelect ()
{
InitializeComponent();
treePstSelect.Visibility = Visibility.Hidden;
List < MailboxHelper.Folder > lstMailBoxHelper = Globals.selectFolder(fileName);
buildTree(lstMailBoxHelper);
treeListView1.ExpandAllNodes();
this.barButtonItem1.ItemClick += this.barButtonItem1_ItemClick;
}
public class ProjectObject
{
public string Name { get; set; }
public string Executor { get; set; }
}
private void buildTree (List<MailboxHelper.Folder> lstMailBoxHelper)
{
TreeListNode rootNode = CreateRootNode(new ProjectObject() { Name = lstMailBoxHelper[0].displayName, Executor = lstMailBoxHelper[1].displayName });
TreeListNode childNode = CreateChildNode(rootNode, new ProjectObject() { Name = lstMailBoxHelper[2].displayName, Executor = lstMailBoxHelper[1].displayName });
CreateChildNode(childNode, new ProjectObject() { Name = lstMailBoxHelper[3].displayName, Executor = lstMailBoxHelper[1].displayName });
}
private TreeListNode CreateRootNode(object dataObject)
{
TreeListNode rootNode = new TreeListNode(dataObject);
treeListView1.Nodes.Add(rootNode);
return rootNode;
}
private TreeListNode CreateChildNode (TreeListNode parentNode, object dataObject)
{
TreeListNode childNode = new TreeListNode(dataObject);
parentNode.Nodes.Add(childNode);
return childNode;
}