Hi,
you can use Storyboard with 2 Timelines like in following demo:
<Window x:Class="WpfApp042.Window042"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp042"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
Title="Rotate" Height="450" Width="800" Loaded="Window_Loaded">
<Grid>
<Canvas>
<Polygon x:Name="image" Points="20, 40 30, 10 40, 40" StrokeThickness="2" Stroke="Black"/>
</Canvas>
</Grid>
</Window>
CodeBehind:
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace WpfApp042
{
/// <summary>
/// Interaction logic for Window042.xaml
/// </summary>
public partial class Window042 : Window
{
public Window042()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
double x = .75;
double y = 1.0;
Storyboard sb = new Storyboard();
RotateTransform rt = new RotateTransform();
NameScope.SetNameScope(this, new NameScope());
this.RegisterName("rotateTransform", rt);
image.RenderTransformOrigin = new Point(x, y);
image.RenderTransform = rt;
DoubleAnimation da1 = new DoubleAnimation(0, 90, new Duration(TimeSpan.FromSeconds(1.0)));
sb.Children.Add(da1);
Storyboard.SetTargetName(da1, "rotateTransform");
Storyboard.SetTargetProperty(da1, new PropertyPath(RotateTransform.AngleProperty));
DoubleAnimation da2 = new DoubleAnimation(90, 360, new Duration(TimeSpan.FromSeconds(3.0)))
{
BeginTime = new TimeSpan(0, 0, 5)
};
sb.Children.Add(da2);
Storyboard.SetTargetName(da2, "rotateTransform");
Storyboard.SetTargetProperty(da2, new PropertyPath(RotateTransform.AngleProperty));
sb.Begin(this);
}
}
}
Result: