在XAML中使用矩形形状作为剪辑 [英] Use a rectangle shape as a clip in XAML

查看:156
本文介绍了在XAML中使用矩形形状作为剪辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法,我可以使用正常的Rectangle(形状)作为XAML中另一个对象的剪辑的一部分。似乎我应该能够,但解决方案是逃避我..

Is there a way that I can use a normal Rectangle (shape) as part of a clip for another object in XAML. It seems like I should be able to, but the solution is eluding me..

<Canvas>

        <Rectangle Name="ClipRect" RadiusY="10" RadiusX="10" Stroke="Black" StrokeThickness="0" Width="32.4" Height="164"/>

<!-- This is the part that I cant quite figure out.... -->
<Rectangle Width="100" Height="100" Clip={Binding ElementName=ClipRect, Path="??"/>

</Canvas>

我知道我可以使用RectangleGeometry类型的方法,但是我对该解决方案更感兴趣

I know that I can use a 'RectangleGeometry' type approach, but I am more interested in the solution in terms of the code presented above.

推荐答案

尝试 Shape.RenderedGeometry属性

<Rectangle Width="100" Height="100"
           Clip="{Binding ElementName=ClipRect, Path=RenderedGeometry}" />

这篇关于在XAML中使用矩形形状作为剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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