使用WPF的TreeView绘制树木

发布于 2024-09-08 17:32:22 字数 378 浏览 1 评论 0原文

我想使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弃爱 2024-09-15 17:32:22

这并不完全是您所要求的,但我分享它以防有帮助... 此博客有一个绘制二叉树的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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文