4

I have a number of scenarios where I am doing simple WPF storyboard animations as such.

<Storyboard x:Key="MyTextBlockStoryBoard" RepeatBehavior="Forever">
    <DoubleAnimation AutoReverse="True"
                    Duration="0:0:8"
                    From="0.0"
                    Storyboard.TargetName="MyTextBlock"
                    Storyboard.TargetProperty="(Canvas.Left)"
                    To="500.0" />

</Storyboard>

However I need to be able to set the To value in this animation to a dynamic value which is equivalent to UserControl.ActualWidth - MyTextBlock.ActualWidth. I understand that obviously I can easily create a Storyboard as above programmatically but I am hoping to stay inside Xaml world.

My inkling is that the only way I can achieve this is through implementing my own IValueConverter but I am hoping that there might be a easier way to achieve my desired output?

Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243

0 Answers0