I am defining a storyboard as a Grid Resource. I have named it. I can set the TargetName property in code, but I cannot figure out how to set the From and To values of the storyboard in code. These values need to be set at runtime. Here is what I have.
<Grid.Resources>
<Storyboard x:Name="btnClick_SB" >
<DoubleAnimation Storyboard.TargetProperty="X2" From="10" To="400" Duration="0:0:1.0" EnableDependentAnimation="True"/>
<DoubleAnimation Storyboard.TargetProperty="Y2" From="10" To="400" Duration="0:0:1.0" EnableDependentAnimation="True"/>
</Storyboard>
...
<Canvas x:Name="cnvBL" Margin="0" Grid.Row="2" Background="White">
<Line x:Name="lineBL1" Stroke="Blue" StrokeThickness="5" />
<Line x:Name="lineBL2" Stroke="Blue" StrokeThickness="5" />
</Canvas>
and the code
lineBL1.X1 = 10;
lineBL1.Y1 = 10;
btnClick_SB.Stop();
btnClick_SB.SetValue(Storyboard.TargetNameProperty, "lineBL1");
btnClick_SB.Begin();
As you can see, From and To are set in XAML. I want to instead set those values in code. How can I do that?