Note that there are some explanatory texts on larger screens.

plurals
  1. POCanvas.GetTop() returning NaN
    primarykey
    data
    text
    <p>I've got a Canvas with a few UIElements on. After I've moved them on the canvas by animating the top and left properties, very occasionally a subsiquent call to Canvas.GetTop results in NaN.</p> <p>Am I not 'closing' the animations properly?</p> <p>Here's how I'm doing the move </p> <pre><code>private void InternalMove(double durationMS, FrameworkElement fElement, Point point, EventHandler callback) { _moveElement = fElement; _destination = point; Duration duration = new Duration(TimeSpan.FromMilliseconds(durationMS)); DoubleAnimation moveLeftAnimation = new DoubleAnimation(Canvas.GetLeft(fElement), point.X, duration, FillBehavior.Stop); Storyboard.SetTargetProperty(moveLeftAnimation, new PropertyPath("(Canvas.Left)")); DoubleAnimation moveTopAnimation = new DoubleAnimation(Canvas.GetTop(fElement), point.Y, duration, FillBehavior.Stop); Storyboard.SetTargetProperty(moveTopAnimation, new PropertyPath("(Canvas.Top)")); // Create a storyboard to contain the animation. _moveStoryboard = new Storyboard(); if (callback != null) _moveStoryboard.Completed += callback; _moveStoryboard.Completed += new EventHandler(s1_Completed); _moveStoryboard.Children.Add(moveLeftAnimation); _moveStoryboard.Children.Add(moveTopAnimation); _moveStoryboard.FillBehavior = FillBehavior.Stop; _moveStoryboard.Begin(fElement); } private void s1_Completed(object sender, EventArgs e) { if (_moveStoryboard != null) { _moveStoryboard.BeginAnimation(Canvas.LeftProperty, null, HandoffBehavior.Compose); _moveStoryboard.BeginAnimation(Canvas.TopProperty, null, HandoffBehavior.Compose); } Canvas.SetLeft(_moveElement, _destination.X); Canvas.SetTop(_moveElement, _destination.Y); } </code></pre> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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