1
有人可以解释此WPF行为吗?使用OpacityMask(XAML)的问题
<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
角落都不再圆润!这个问题实际上是一个我在我的软件中遇到的问题的“缩小”例子,它使用了类似的掩码。
我该如何解决这个问题?