I have a Shape inside Canvas, like this:
<ScrollViewer>
<Border Height="342" Width="470" HorizontalAlignment="Left"
VerticalAlignment="Top" BorderThickness="3" BorderBrush="Black">
<Canvas Background="White">
<Rectangle Width="200" Height="200" Canvas.Left="103"
Canvas.Top="186" Fill="Red" />
</Canvas>
</Border>
</ScrollViewer>
Even if the Rectangle is a Canvas children it's draw outside Canvas limits, covering Border bottom border. How can I make the Rectangle is draw only inside Canvas limits, ensuring that the part of rectangle that lies beyond is not displayed?
Thanks.
This is what the ClipToBounds property was made for:
<Canvas Background="White" ClipToBounds="True">
<Rectangle Width="200" Height="200" Canvas.Left="103" Canvas.Top="186" Fill="Red" />
</Canvas>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With