UIElement.Clip in Silverlight for Windows Phone
I have the following element inside a template, which is supposed to create a rectangle with a hollow section in the middle. It is shown ok in Blend, but in the phone or the emulator the Clip property is ignored and it's shown as a plain rectangle.
<Border x:Name="Background" Background="#FF3FC4FF" Clip="M0,0L0,0L94,0L94,94L0,94M6,6L6,6L88,6L88,61L6,61" />
Is the UI开发者_开发技巧Element.Clip property supposed to work in WP7?
Thanks in advance.
Yes, it should work:
<Border x:Name="Background" BorderThickness="2" Margin="10,10,0,10" CornerRadius="5">
<Image Height="50" Width="50" HorizontalAlignment="Center" VerticalAlignment="Top" Source="{Binding ImageUrl, Mode=OneWay}" >
<Image.Clip>
<RectangleGeometry RadiusX="5" RadiusY="5" Rect="0, 0, 50, 50" />
</Image.Clip>
</Image>
</Border>
Ofcurse You can change Image of background to something else (canvas?) and geometry of Clip.
Thanks for your help. I finally made it work by rearranging the points in the path:
<Border x:Name="Background" Fill="#FF3FC4FF" Clip="M0,0L94,0L94,61L88,61L88,6L6,6L6,61L0,61L0,85L94,85L94,61L0,61" />
精彩评论