简体   繁体   English

如何解析XamPivotGrid的层次结构?

[英]How can I parse the hierarchy of a XamPivotGrid?

I'm working on writing an attached behavior to duplicate column and row expansion across two XamPivotGrid s which have different data sources. 我正在写一个附加的行为,以复制具有不同数据源的两个XamPivotGrid的列和行扩展。

The behavior works, but at any hierarchy level other than the outermost, all rows expand simultaneously. 该行为有效,但是在除最外层之外的任何层次结构级别上,所有行均同时展开。 I'd like to filter my query for header rows to only get a header with the same parent. 我想过滤查询中的标题行,以仅获取具有相同父项的标题。 Herein lies the problem: 问题出在这里:

My initial pivot grid has four measures, one row, and one column. 我最初的枢轴网格有四个度量,一行和一列。 Only one measure is selected by default. 默认情况下,仅选择一种度量。 To create a hierarchy, I (using the XamPivotDataSelector control) drag the column to also act as a row, which makes the measure act as the column. 为了创建层次结构,我(使用XamPivotDataSelector控件)将列拖动为行,从而使度量充当列。 While this appears to be a hierarchy on the pivot grid, in actuality one is still one of the grid's RowHeaders and the other a ColumnHeader - they share no relationship I can access. 尽管这似乎是枢轴网格上的层次结构,但实际上一个仍然是网格的RowHeaders之一,另一个仍然是ColumnHeader-它们没有共享的关系我可以访问。

After searching online, I haven't found any information on how I might go about accessing whatever it is that can be used to identify a particular header. 在线搜索后,我没有找到有关如何访问可用来识别特定标头的信息。 I realize that this question may require sufficiently deep knowledge of the XamPivotGrid control that I may never get an answer, so I will continue poring over the grid in the hopes that I may be able to answer this question myself. 我意识到这个问题可能需要足够深入的XamPivotGrid控件知识,以至于我可能永远也XamPivotGrid答案,因此我将继续研究网格,希望自己能够自己回答这个问题。

Thank you for your time. 感谢您的时间。

UPDATE: I have found that the columns do indeed become rows rather than columns, so at least that much makes more sense, but they are simply in a list, rather than being hierarchically arranged. 更新:我发现列的确确实变成了行而不是列,因此至少这样做更有意义,但它们只是在列表中,而不是按层次排列。

It turns out that the row/column structure when there's a hierarchy does in fact simulate a tree. 事实证明,存在层次结构时,行/列结构实际上模拟了树。 Because I don't have experience converting a list to a tree, and because the two grids I deal with are always going to have the same rows and columns, I was able to do something different. 因为我没有将列表转换为树的经验,并且由于我处理的两个网格始终具有相同的行和列,所以我能够做些不同的事情。

Essentially, grid.GridLayout.RowHeaderCells items are guaranteed to have the same index in all grids. 本质上, grid.GridLayout.RowHeaderCells项在所有网格中都保证具有相同的索引。 I don't have to deal with trees, just an index. 我不必处理树木,只需要索引即可。

EDIT: 编辑:

In fact, this solution turned out to be unhelpful in my case, because while rows and columns remain the same, they may be hidden. 实际上,对于我来说,这种解决方案无济于事,因为尽管行和列保持不变,但它们可能是隐藏的。 Instead, I found i was able to use PivotHeaderCell.Member.Tuple.ToString() to reliably generate the 'path' I was searching for in my question, so everything is now better. 相反,我发现我能够使用PivotHeaderCell.Member.Tuple.ToString()可靠地生成我在问题中搜索的“路径”,所以现在一切都变得更好了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM