0

我为添加阴影的标签创建了一种样式:

<Style TargetType="Label" x:Key="BigLabel">
    <Setter Property="FontSize" Value="35" />
    <!-- some more... -->
    <Setter Property="Effect">
        <Setter.Value>
            <DropShadowEffect BlurRadius="0" Opacity="0.9" ShadowDepth="5" />
        </Setter.Value>
    </Setter>
</Style>

我要使用该样式的标签之一已旋转。现在,当我以这种方式应用样式时:

<Label Content="Awesome" Style="{StaticResource BigLabel}" >
    <Label.LayoutTransform>
        <RotateTransform Angle="-90" />
    </Label.LayoutTransform>
</Label>

然后结果是,从标签的角度看,投影仍然进入相同的方向(右下),但从用户的角度看(右上)进入不同的方向。现在由于有多个标签,有些是旋转的,有些不是,我希望从用户的角度来看,阴影都进入相同的方向,右下角。

这意味着要么我必须Direction在旋转的标签上设置不同的值,要么告诉 WPF在旋转应用带有阴影的样式。现在我想知道:

有没有办法告诉 WPF 先旋转然后应用样式?

4

1 回答 1

1

试试这个,使用 Direction 属性:

    <Style TargetType="Label" x:Key="BigLabel">
        <Setter Property="FontSize" Value="35" />
        <!-- some more... -->
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect BlurRadius="5" Opacity="0.92" ShadowDepth="3" Direction="225" />
            </Setter.Value>
        </Setter>
    </Style>
于 2013-10-10T13:24:40.147 回答