WPF中的负边距

时间:2015-08-01 11:29:02

标签: wpf margin

当我设置边缘边缘负值时,我希望它们仍然在父面板内,但要使用父边框裁剪。 这就是我所拥有的:enter image description here

这就是我想要的(涂上油漆): enter image description here

我的XAML:

    <Grid HorizontalAlignment="Left" Height="97" Margin="113,60,0,0" VerticalAlignment="Top" Width="125" Background="#FFF97C7C">
        <Ellipse Fill="#FFF4F5F4" Height="56" Margin="-48,-22,-46,63" Stroke="Black"/>
    </Grid>

我该怎么做?

1 个答案:

答案 0 :(得分:6)

使用ClipToBounds

<Grid ClipToBounds="True" HorizontalAlignment="Left" Height="97" Margin="113,60,0,0" VerticalAlignment="Top" Width="125" Background="#FFF97C7C">
    <Ellipse Fill="#FFF4F5F4" Height="56" Margin="-48,-22,-46,63" Stroke="Black"/>
</Grid>

结果:

Result