如何专门绘制形状内画布 [英] How to draw Shape exclusively inside Canvas

查看:156
本文介绍了如何专门绘制形状内画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有内部帆布一个Shape ,像这样的:

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?

感谢。

推荐答案

这是什么<一个href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.cliptobounds.aspx">ClipToBounds财产是为:

<Canvas Background="White" ClipToBounds="True"> 
    <Rectangle Width="200" Height="200" Canvas.Left="103" Canvas.Top="186" Fill="Red" /> 
</Canvas> 

这篇关于如何专门绘制形状内画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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