将 Treeview 绑定到具有 WPF 中相同对象列表的对象
我正在尝试制作报告树视图。我可以在其中编写一些文本作为父节点,如果需要,我可以添加添加字符串作为子节点以显示更多信息。
我制作了一个报告对象:
public class Report
{
private List<Report> reportList = new List<Report>();
public string Text { get; set; }
public List<Report> Reports
{
get
{
return reportList;
}
set
{
reportList = value;
}
}
}
然后我有一个报告集合,然后我将其输入到树视图项目源中,但我不知道如何创建绑定,以便它能够在整个过程中正确创建子节点,我尝试搜索谷歌,但是我找不到正确的方法。
有人可以帮助我吗?
I'm trying to make a report treeview thing. Where I could write some text to have as a parent node, and if need be I'd add add strings as sub nodes to display some more information.
I made a report object:
public class Report
{
private List<Report> reportList = new List<Report>();
public string Text { get; set; }
public List<Report> Reports
{
get
{
return reportList;
}
set
{
reportList = value;
}
}
}
Then I'd have a Report Collection that I would then feed into a treeview itemssource, but I have no idea how to create the bindings so that it will create the subnodes properly throughtout, I tried searching google, but I couldn't find the correct way.
Can anybody inhere help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
HierarchicalDataTemplate
You need to use a
HierarchicalDataTemplate