【发布时间】:2010-07-08 10:40:29
【问题描述】:
有人可以解释这种 WPF 行为吗?
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<!-- Rounded mask -->
<Border Name="mask" VerticalAlignment="Top" Background="Black" CornerRadius="48" Height="400" Width="400" />
<StackPanel>
<!-- Use a VisualBrush of 'mask' as the opacity mask -->
<StackPanel.OpacityMask>
<VisualBrush Visual="{Binding ElementName=mask}" />
</StackPanel.OpacityMask>
<Grid>
<Border Background="Red" Height="400" Width="400"/>
<Border Background="Blue" Height="200" Width="400"/>
</Grid>
</StackPanel>
</Grid>
</Page>
如我所料,上面的代码生成了以下图像(Kaxaml):
alt text http://robbertdam.nl/share/11.png
当我换行时
<Border Background="Blue" Height="200" Width="400"/>
在
<Border Background="Blue" Height="200" Width="600"/>
图片如下(没想到):
alt text http://robbertdam.nl/share/12.png
角落不再是圆的!这个问题实际上是我在使用类似掩码的软件中遇到的问题的“缩小”示例。
我该如何解决这个问题?
【问题讨论】:
标签: wpf silverlight xaml