0

为什么VisualTreeHelper.GetDescendantBounds(SomeVisualItem)方法返回(-Infinity,-Infinity,Infinity,Infinity)

SomeVisualItem 的Canvas.Left, Canvas.Top, Width, ... 是显式分配的。

4

1 回答 1

2

我解决了。只是我从控件的 ControlTemplate 中的 ViewBox 中删除了效果:

<Viewbox Opacity=".7" Stretch="Uniform" IsHitTestVisible="False" FocusVisualStyle="{x:Null}" IsEnabled="False" ForceCursor="False" x:Name="PART_OutThumb">
    <Viewbox.Effect>
        <BlurEffect KernelType="Gaussian" Radius="1" />
    </Viewbox.Effect>
</Viewbox>

到:

<Viewbox Opacity=".7" Stretch="Uniform" IsHitTestVisible="False" FocusVisualStyle="{x:Null}" IsEnabled="False" ForceCursor="False" x:Name="PART_OutThumb">
</Viewbox>

现在VisualTreeHelper.GetDescendantBounds()效果很好!

于 2012-03-06T09:28:32.053 回答