I've got this in my XAML:
<Grid.Resources>
<Storyboard x:Name="Storyboard_Animation">
<DoubleAnimation
Storyboard.TargetName="button_Submit"
Storyboard.TargetProperty="Angle"
From="0"
To="360"
Duration="0:0:1"></DoubleAnimation>
</Storyboard>
</Grid.Resources>
I have the button in the same Grid:
<Button Grid.Row="0" Grid.Column="1" Content="Submit" Margin="0" Name="button_Submit" Click="button_Submit_Click">
<Button.Template>
<ControlTemplate>
<Image Source="Images/buttonImage.png"></Image>
</ControlTemplate>
</Button.Template>
<Button.RenderTransform>
<RotateTransform></RotateTransform>
</Button.RenderTransform>
</Button>
I have this in my click method:
private void button_Submit_Click(object sender, RoutedEventArgs e)
{
Storyboard_Animation.Begin();
}
When I click on my button I get the error: Cannot resolve TargetProperty Angle on specified object.
But, I have no idea what I'm supposed to use other than Angle.
I have this other piece of code that works fine:
private void RotateStar()
{
button_Submit.RenderTransformOrigin = new Point(0.5, 0.5);
button_Submit.RenderTransform = new RotateTransform();
DoubleAnimation da = new DoubleAnimation
{
From = 0,
To = 360,
Duration = TimeSpan.FromSeconds(0.3)
};
Storyboard.SetTarget(da, button_Submit.RenderTransform);
Storyboard.SetTargetProperty(da, new PropertyPath(RotateTransform.AngleProperty));
Storyboard sb = new Storyboard();
sb.Children.Add(da);
sb.Begin();
}
I'd like to put the storyboard in the XAML instead of in code. What do I need to add/change in my XAML version so that it works like the code version?