为什么会发生这种削波

时间:2011-07-08 00:48:56

标签: silverlight silverlight-4.0

请注意,在代码中我没有在网格上添加任何剪辑,为什么显示的矩形被裁剪为网格​​的大小。

我添加偏移量只是为了表明即使我将它移到侧面,网格的填充也不是红色。

    <Grid Height="135" Width="162">
        <Rectangle Width="300" Height="249" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#FFDB1919" UseLayoutRounding="False">
            <Rectangle.Projection>
                <PlaneProjection LocalOffsetX="-42"/>
            </Rectangle.Projection>

        </Rectangle>
    </Grid>

2 个答案:

答案 0 :(得分:2)

网格默认情况下会剪切内容。

最快的解决方法是将矩形放在画布中(默认情况下没有剪裁):

<Grid Height="135" Width="162">
    <Canvas>
        <Rectangle Width="300" Height="249" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#FFDB1919" UseLayoutRounding="False" StrokeThickness="5">
            <Rectangle.Projection>
                <PlaneProjection LocalOffsetX="-42"/>
            </Rectangle.Projection>
        </Rectangle>
    </Canvas>
</Grid>

enter image description here

答案 1 :(得分:1)

这就是这里发生的事情:

1. WPF layout is done. it will place the 
   rectangle in the center as it was specified.
2. The rectangle will be clipped by the Grid.
3. The Projection transformation is applied after all this stuff.
   In your case you did move already clipped rectangle by -42 pixels