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
角落都不再圓潤!這個問題實際上是一個我在我的軟件中遇到的問題的「縮小」例子,它使用了類似的掩碼。
我該如何解決這個問題?