Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display content inside control when used negative margin.

For example I have 2 Grids, like this:

<Grid  Height="200" Width="200" Background="Red">
    <Grid HorizontalAlignment="Left" Height="100" Width="100" Background="Blue" Margin="-30,0,0,0" />
</Grid>

And result looks:

enter image description here

How I can create that content will display only inside control when used negative margin?
Like this:

enter image description here

like image 807
jimpanzer Avatar asked Feb 03 '26 07:02

jimpanzer


1 Answers

You can use ClipToBounds="True" for Grid or other container of elements.

  <Grid>  
    <Grid  Height="200" Width="200" Background="Red" ClipToBounds="True">
        <Grid HorizontalAlignment="Left" Height="100" Width="100" Background="Blue" Margin="-30,0,0,0" />
    </Grid>
  </Grid>
like image 130
sashok-batman Avatar answered Feb 04 '26 23:02

sashok-batman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!