I’ll try to make this as simple as I can.
I want to do this:
<Storyboard x:Name="MoveToLocation">
<DoubleAnimation Duration="0:0:0.5" To="{Binding X}" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
</Storyboard>
As you may have noticed the Binding on ‘To’ Property does not work. It seems to only accept static values.
How does one do this animation with MVVM? I cant just put in static data, cause it’s going to change.
Thanks.
DoubleAnimationis also not aFrameworkElementhence binding doesn’t work to that either. See my answer to your previous question.In order to achieve your goal here you will need to take the contents of your
DataTemplateand turn it into aUserControl. This new control can then expose a set of dependency properties that you need to bind to, including one forTovalue of the storyboard.