使用WPF的TreeView绘制树木
我想使用 WPF System.Windows.Controls.TreeView
以图形/网络布局(例如 graphviz)的方式可视化树。当然,TreeView
控件的默认布局看起来像 Windows 资源管理器的目录查看器。因此,我需要更改布局,将根放在顶部,其子项在其下方间隔开,依此类推。
此外,我想通过 F# 以编程方式执行此操作。我找到的所有相关示例(例如 这个 )使用一堆 XAML 来完成此操作,但我无法将其转换为 F# 代码。
I'd like to use a WPF System.Windows.Controls.TreeView
to visualize a tree in the style of graph/network layout (e.g. graphviz). The default layout of the TreeView
control looks, of course, like Windows Explorer's directory viewer. So I need to change the layout to put the root at the top, its children spaced out beneath it and so on.
Moreover, I'd like to do this programmatically from F#. All of the related samples I have found (e.g. this one) do this using a pile of XAML and I have not been able to translate it into F# code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这并不完全是您所要求的,但我分享它以防有帮助... 此博客有一个绘制二叉树的WPF代码示例(但布局很简单/愚蠢)。
编辑
哦,是的,您也许可以与此处的代码结合使用:
漂亮地打印一棵树
这是控制台漂亮的打印和良好的布局,也许这两部分一起会带来一些不错的结果(我没有尝试过)。
This is not exactly what you're asking for, but I share it in case it helps... this blog has an example of WPF-code to draw binary trees (but the layout is simple/dumb).
EDIT
Oh yeah, you can maybe combine with code here:
Pretty print a tree
which was console pretty-printing with good layout, and maybe together the two pieces lead to something nice (I have not tried).