WPF - 动态重新排列控制层次结构
如何动态填充容器?假设用小圆圈递归地填充大圆圈。只要填满空间就可以了。
我想用它来显示数据层次结构。
为了明确起见:
How is it possible to dynamically fill a container? Let's say to fill a big circle with small circles, recursively. Just fill the space fine.
I would like to use it for data hierarchy display.
To make it clear:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要现成的东西,请查看 Graph#
http://graphsharp.codeplex.com/
视频在这里:
http://www.youtube.com/watch?v=VTbuvkaPGxE
http://www.youtube.com/watch?v=agDPDzqB4o0&feature=lated
它具有动态图形布局并且相当易于使用。有多种布局算法可供选择[请参阅示例应用程序],每种算法都是可配置的。
然而,填充直到一个区域“满”并不是开箱即用的。例如,尽管您可以创建一个图表,将其布局并显示出来。然后测量顶点大小与整个图大小之间的比率,然后添加或删除顶点,直到达到所需的密度。我敢说你可以通过反复试验很快地在要填充的画布大小和要填充的画布大小之间找到一个快速而肮脏的公式。您应该添加的顶点数。
请注意,您可以轻松地将顶点模板自定义为任何类型的数据 [这是标准 wpf,但 Graph# 特定示例可以在 http://graphsharp.codeplex.com/discussions ]
如果您想编写自己的布局代码,您可能想看看 Graph# 使用的一些技术...例如动态缩放组件的源代码可在此处找到: http://wpfextensions.codeplex.com/
希望有所帮助
If you want something off the shelf, have a look at Graph#
http://graphsharp.codeplex.com/
videos here:
http://www.youtube.com/watch?v=VTbuvkaPGxE
http://www.youtube.com/watch?v=agDPDzqB4o0&feature=related
It does dynamic graph layout and is fairly easy to use. There are a choice of layout algorithms [see sample app] each of which are configurable.
however filling until an area is "full" is not something that'll work out of the box. Although you could for example create a graph, lay it out & then measure the ratio between the size of a vertex and the size of the whole graph, then add or remove vertexes until you hit upon your desired density. I would hazard you could pretty quickly by trial and error come up with a quick and dirty forumula between the size of canvas to fill & the number of vertexes you should add.
Note that you can customise the vertex templates pretty easily to be any kind of data [this is standard wpf but Graph# specific examples can be found on http://graphsharp.codeplex.com/discussions ]
if you wanted to code your own layout you might like to have a look at some of the techniques Graph# use... for example a dynamic zoom component the source for which is available here: http://wpfextensions.codeplex.com/
hope that helps a little