WPF Adorner剪辑 [英] WPF Adorner Clipping
问题描述
我在 ScrollViewer
中有一个 ItemsControl
。 ItemsControl
中的项目被扩展为 DataTemplate
,该模板基本上由 Adorner 组成。 code>。
I have an ItemsControl
in a ScrollViewer
. The items in the ItemsControl
are expanded to a DataTemplate
which basically consists of an Adorner
.
现在的问题是,滚动时, Adorner
的可视子级可见在 ScrollViewer
之外。假设我从水平偏移量 0滚动到100, Adorner
的可视子级向左移动,并且在 ScrollViewer旁边可见
,尽管它们应该被隐藏。在 ItemsControl
或 ScrollViewer
上设置 ClipToBounds
无效。
Now the problem is, when scrolling, the Visual Children of the Adorner
are visible outside the ScrollViewer
. Lets say I scroll from the Horizontal Offset 0 to 100, the Visual Children of the Adorner
move to the left and are visible next to the ScrollViewer
, although they should be hidden. Setting ClipToBounds
on the ItemsControl
or the ScrollViewer
does not work.
我了解到, Adorner
在所有元素上都是按z顺序排列的,但实际上不应该在 ScrollViewer
这样的情况下可见。装饰的 Element
的行为与预期的一样,并且不能通过 ScrollViewer
看到。
I understand, that Adorner
are rendered above all elements z-order wise, but they really shouldn't be visible in such cases as with the ScrollViewer
. The adorned Element
by the way behaves like expected and is not visible through the ScrollViewer
.
是否有任何简便的方法来剪切 Adorner
,以便它们仅在可见的滚动区域中可见?
Is there any easy way to "clip" the Adorner
s, so that they are only visible in the visible scroll area?
谢谢,
Andrej
Thanks, Andrej
推荐答案
设置包含控件上的ClipToBounds
是不够的。您还必须设置装饰者的 IsClipEnabled
属性。
Setting ClipToBounds
on the containing control is not enough. You must set the adorner's IsClipEnabled
property too.
这篇关于WPF Adorner剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!