根节点水平后如何垂直布局树视图项目?
好吧,我想做的就是这样的事情。
|--> Child 1 (Parent=Root 2)
|
| Child 2.0 (Parent=Child 2)
| Child 2.1 (Parent=Child 2)
|--> Child 2 (Parent=Root 2) -------> Child 2.2 (Parent=Child 2)
| Child 2.3 (Parent=Child 2)
| Child 2.4 (Parent=Child 2)
| Child 2.5 (Parent=Child 2)
|
|--> Child 3 (Parent=Root 2)
Root ------- Root 2 -----> Child 4 (Parent=Root 2) -----> Root 3 ------> Root 4
|--> Child 5 (Parent=Root 2)
|
| Child 2.0 (Parent=Child 6)
| Child 2.1 (Parent=Child 6)
|--> Child 6 (Parent=Root 2) ------> Child 2.2 (Parent=Child 6)
| Child 2.3 (Parent=Child 2)
| Child 2.4 (Parent=Child 2)
|
|--> Child 7 (Parent=Root 2)
基本上每个根元素都是水平的,所以我使用具有水平方向的 VirtualizingStackPanel。这正是我现在想要的。现在我面临的问题是孩子们。我基本上希望子元素在作为子元素的父节点的根 2 元素的右侧进行操作。
我正在模拟一棵实际上是水平树而不是垂直树。
Okay what I want to do is something like this.
|--> Child 1 (Parent=Root 2)
|
| Child 2.0 (Parent=Child 2)
| Child 2.1 (Parent=Child 2)
|--> Child 2 (Parent=Root 2) -------> Child 2.2 (Parent=Child 2)
| Child 2.3 (Parent=Child 2)
| Child 2.4 (Parent=Child 2)
| Child 2.5 (Parent=Child 2)
|
|--> Child 3 (Parent=Root 2)
Root ------- Root 2 -----> Child 4 (Parent=Root 2) -----> Root 3 ------> Root 4
|--> Child 5 (Parent=Root 2)
|
| Child 2.0 (Parent=Child 6)
| Child 2.1 (Parent=Child 6)
|--> Child 6 (Parent=Root 2) ------> Child 2.2 (Parent=Child 6)
| Child 2.3 (Parent=Child 2)
| Child 2.4 (Parent=Child 2)
|
|--> Child 7 (Parent=Root 2)
Basically each Root element is Horizontal so I am using a VirtualizingStackPanel with Orientation Horizontal. Which is exactly what I want right now. Now the problem I have is the children. I basically want the Children to operate to the right of the Root 2 Element who is the parent node of the children.
I am simulating a Tree that is actually Horizontal instead of a Vertical tree.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解你的问题那么你想要这样的东西吗?
我在每个 TreeViewItem 周围添加了一个 1px 的黑色边框,以查看哪些内容去了哪里,以便可以删除该部分。
我想不出任何其他解决方案来为此重新模板 TreeViewItem。首先,我像您一样使用了 Horizontal VirtualizingStackPanel。然后我删除了 RowDefinitions 并在 TreeViewItem 模板中添加了另一个 ColumnDefinition。为了获得列的匹配宽度,我对中间列使用了 IsSharedSizeScope。
这是 Xaml
If I understood your question correctly then you want something like this?
I added a 1px black border around each TreeViewItem to see what went where so that part can be removed.
I can't think of any other solution then to re-template TreeViewItem for this. First I used a Horizontal VirtualizingStackPanel like you did. Then I removed the RowDefinitions and added another ColumnDefinition in the TreeViewItem template. To get matching Widths for the Columns I used IsSharedSizeScope for the Middle Column.
Here's the Xaml