gpt4 book ai didi

WPf 路径旋转不起作用

转载 作者:行者123 更新时间:2023-12-01 15:54:24 27 4
gpt4 key购买 nike

我想在更改数据上下文中的属性时旋转路径。我添加了一个颜色变化来查看实际执行的 Storyboard 。但是没有旋转...

<Grid Grid.Column="0" Grid.Row="0" Background="Green" Margin="0,10,10,10" Width="100" Height="100">
<Grid.Resources>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Expanded}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<local:BrushAnimation Duration="0:0:1" To="Red" Storyboard.TargetProperty="Fill"/>
<DoubleAnimation Duration="0:0:1" To="45" Storyboard.TargetProperty="(LayoutTransform).(RotateTransform.Angle)"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:2" To="90" Storyboard.TargetProperty="(LayoutTransform).(RotateTransform.Angle)"/>
<local:BrushAnimation Duration="0:0:2" To="Yellow" Storyboard.TargetProperty="Fill"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>

<Path VerticalAlignment="Stretch" Fill="Aqua" Stretch="Uniform" RenderTransformOrigin="0.5, 0.5">
<Path.Data>
<StreamGeometry>F1M154.2217,60.96L45.7777,100L154.2217,139.04z</StreamGeometry>
</Path.Data>
</Path>
</Grid>

最佳答案

你必须先添加一个RotateTransform到你的Path

<Path VerticalAlignment="Stretch" Fill="Aqua" Stretch="Uniform" RenderTransformOrigin="0.5, 0.5" x:Name="Path">
<Path.Data>
<StreamGeometry>F1M154.2217,60.96L45.7777,100L154.2217,139.04z</StreamGeometry>
</Path.Data>
<Path.LayoutTransform>
<RotateTransform Angle="0"></RotateTransform>
</Path.LayoutTransform>
</Path>

关于WPf 路径旋转不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38121067/

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