Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm sure this is wrong for SO many reasons and please feel free to tell me how many WPF laws I've violated but.. I solved the same problem by creating my own BindableDoubleAnimation.</p> <pre><code>public class BindableDoubleAnimation : DoubleAnimationBase { DoubleAnimation internalAnimation; public DoubleAnimation InternalAnimation { get { return internalAnimation; } } public double To { get { return (double)GetValue(ToProperty); } set { SetValue(ToProperty, value); } } /// &lt;summary&gt; /// Dependency backing property for the &lt;see cref="To"/&gt; property. /// &lt;/summary&gt; public static readonly DependencyProperty ToProperty = DependencyProperty.Register("To", typeof(double), typeof(BindableDoubleAnimation), new UIPropertyMetadata(0d, new PropertyChangedCallback((s, e) =&gt; { BindableDoubleAnimation sender = (BindableDoubleAnimation)s; sender.internalAnimation.To = (double)e.NewValue; }))); public double From { get { return (double)GetValue(FromProperty); } set { SetValue(FromProperty, value); } } /// &lt;summary&gt; /// Dependency backing property for the &lt;see cref="From"/&gt; property. /// &lt;/summary&gt; public static readonly DependencyProperty FromProperty = DependencyProperty.Register("From", typeof(double), typeof(BindableDoubleAnimation), new UIPropertyMetadata(0d, new PropertyChangedCallback((s, e) =&gt; { BindableDoubleAnimation sender = (BindableDoubleAnimation)s; sender.internalAnimation.From = (double)e.NewValue; }))); public BindableDoubleAnimation() { internalAnimation = new DoubleAnimation(); } protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock) { return internalAnimation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, animationClock); } protected override Freezable CreateInstanceCore() { return internalAnimation.Clone();; } } </code></pre> <p>I'm now free to use bindings for the To From properties.</p> <pre><code>&lt;local:BindableDoubleAnimation Storyboard.TargetProperty="Width" From="0" To="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Window}}"/&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload