gpt4 book ai didi

WPF RotateTransform DataTrigger

转载 作者:行者123 更新时间:2023-12-03 20:24:52 24 4
gpt4 key购买 nike

是否可以使用 DataTrigger 在 WPF 中设置 RotateTransform 的角度?如果是这样,如何?

最佳答案

当然,这样的事情应该有效

<TextBox>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
Value="RotateMe">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="45"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>

或者,如果您已经拥有 LayoutTransform设置,你可以使用 EnterActionsExitActionsDataTrigger
<TextBox>
<TextBox.LayoutTransform>
<RotateTransform Angle="0"/>
</TextBox.LayoutTransform>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
Value="RotateMe">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0"
To="45"
Storyboard.TargetProperty="(LayoutTransform).(RotateTransform.Angle)"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0"
To="0"
Storyboard.TargetProperty="(LayoutTransform).(RotateTransform.Angle)"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>

关于WPF RotateTransform DataTrigger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10437024/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com