0

这通常是如何处理的?我有这个 xaml:

    <Border Grid.Column="1" HorizontalAlignment="Right" 
        VerticalAlignment="Top" Margin="10,25,10,0" Opacity="0.7" 
        BorderBrush="Black" BorderThickness="1" CornerRadius="5">
        <StackPanel>
            <StackPanel.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Color="LightGray" Offset="0.0" />
                    <GradientStop Color="Gray" Offset="1.0" />
                </LinearGradientBrush>
            </StackPanel.Background>

StackPanel 的左上角和右上角是 LightGray,并且似乎位于 Border 的顶部,因此圆角黑色角的中间是一个或两个 LightGray 像素,打破了圆角。底部边框是灰色而不是黑色。

我想我会用上面的代码得到一个带有圆角的 StackPanel ......

4

1 回答 1

1

我建议将背景放在 Border 而不是 Stackpanel

<Border Grid.Column="1" HorizontalAlignment="Right" 
    VerticalAlignment="Top" Margin="10,25,10,0" Opacity="0.7" 
    BorderBrush="Black" BorderThickness="1" CornerRadius="5">
    <Border.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
            <GradientStop Color="LightGray" Offset="0.0" />
            <GradientStop Color="Gray" Offset="1.0" />
        </LinearGradientBrush>
    </Border.Background>
    <StackPanel>
        <!-- Items here -->
    </StackPanel>
</Border>
于 2012-09-06T16:26:39.783 回答