I'm trying to bind my DoubleAnimation
properties to c# variables in the code-behind.
This is my XAML:
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded" >
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Left " Name ="PlayAnimation">
<DoubleAnimation From="{Binding StartAmount}" To="{Binding EndAmount}" Duration="0:0:0.050"
AutoReverse="True" RepeatBehavior="Forever"
FillBehavior="Stop"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Window.Triggers>
In the MainWindow
public MainWindow()
{
InitializeComponent();
int StartAmount = 50;
int EndAmount = 100;
}
After launching the program I just getting the exception
Cannot animate the 'Left' property on a 'WpfApplication4.MainWindow' using a 'System.Windows.Media.Animation.DoubleAnimation'. For details see the inner exception.
Does anyone has an idea why it is throwing this exception?