我有一个LinearGradientBrush,我正在尝试将RotateTransform偏移应用于它。使用此代码,它会旋转并保持静止在我给它的角度:
<LinearGradientBrush.Transform>
<RotateTransform CenterX="60" CenterY="30" Angle="45" />
</LinearGradientBrush.Transform>
有没有办法制作&#34; Angle&#34;动态,所以刷子会旋转180度?
答案 0 :(得分:0)
您可以在RotateTransform的Angle
属性上运行DoubleAnimation,如下例所示,LinearGradientBrush填充Rectangle,动画在加载Rectangle时启动,然后永久运行:
<Rectangle Width="300" Height="300">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="Black" Offset="1"/>
<LinearGradientBrush.Transform>
<RotateTransform CenterX="150" CenterY="150"/>
</LinearGradientBrush.Transform>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Fill.Transform.Angle"
To="360" Duration="0:0:5" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>