问题
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):
My 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>
How can I do it?
回答1:
Use 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:
来源:https://stackoverflow.com/questions/31761307/negative-margin-in-wpf