LayoutTransform自定义样式wpf

时间:2017-01-10 21:04:14

标签: wpf xaml binding

我正在尝试设置自定义样式来旋转分隔符。

此代码有效,但不是自定义样式:

 <Separator>
    <Separator.LayoutTransform>
       <RotateTransform Angle="90" />
    </Separator.LayoutTransform>
 </Separator>

以下是我的尝试:

<Style x:Key="CustomStandaloneSeparatorStyle" TargetType="Separator">
            <Setter TargetName="LayoutTransformProperty" Property="RotateTransform.Angle" Value="{Binding ToolbarTrayElementRotation}" />
            <Setter Property="Margin" Value="2"/>
</Style>

错误消息为:“无法识别LayoutTransformProperty”。但是,当标签填写该条目时,它可作为选项提供......很奇怪。

2 个答案:

答案 0 :(得分:3)

您应该将LayoutTransform属性设置为RotateTransform的实例:

<Style x:Key="CustomStandaloneSeparatorStyle" TargetType="Separator">
    <Setter Property="LayoutTransform">
        <Setter.Value>
            <RotateTransform Angle="90" />
        </Setter.Value>
    </Setter>
</Style>

答案 1 :(得分:1)

该属性称为LayoutTransform:

<Style x:Key="CustomStandaloneSeparatorStyle" TargetType="Separator">
    <Setter Property="LayoutTransform">
        <Setter.Value>
            <RotateTransform Angle="{Binding ToolbarTrayElementRotation}" />
        </Setter.Value>
    </Setter>
    <Setter Property="Margin" Value="2"/>
</Style>