0

I have an Expander control and i need to calculate its bounds without invisible elements and margins. It commonly can be done by VisualTreeHelper.GetDescendantsBounds. But it seems that the rect is calculated by VisualTreeHelper doesn't depend on the expander state. For example:

http://i.piccy.info/i5/58/39/273958/collapsed.jpg

(i can't post images. sorry)

The same result as for expanded state (light green rectangle on the image). Does anybody know how to solve this problem?

4

2 回答 2

0

Expander 控件会将其内容的可见性设置为 Collapsed,这意味着在布局期间不会考虑它,也不会包含在 GetDescendantBounds 中。但是,可以通过布局引擎强制扩展器具有更大的尺寸,并且扩展器自身的尺寸包含在 GetDescendantBounds 中。

尝试VerticalAlignment="Top"在扩展器上进行设置。默认值为Stretch,如果父级有更多可用空间,这将允许它增加大小。还要确保您没有明确设置该Height属性。

于 2010-07-05T13:23:36.553 回答
0

这是示例应用程序。该样式在此处应用于 TreeView 控件及其项。但问题并不取决于风格。

于 2010-07-06T06:15:10.567 回答