当我从数据上下文更改属性时,我想旋转路径。我添加了一个colorchange来查看情节提要实际上正在执行。但是没有旋转...
<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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句