WPF中的负保证金 [英] Negative Margin in WPF

查看:103
本文介绍了WPF中的负保证金的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将边距边缘设置为负值时,我希望它们仍在父面板内,但要使用父边框进行裁切. 这就是我所拥有的:

When I set margin edges negative values, I want them still be inside the parent panel, but to cropped with parent border. This is What i have:

这就是我想要的(用油漆制造):

and this is what I want (made in paint):

我的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>

我该怎么办?

推荐答案

使用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>

结果:

这篇关于WPF中的负保证金的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆