Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem after animation has been applied

0 views
Skip to first unread message

Ranj

unread,
Apr 25, 2006, 5:44:53 AM4/25/06
to
Hi

I have the following problem:

I have an Ellipse Geometry that I animate by updating its Translate
Transfrom X and Y properties,
the animation runs fine but when attempting to place the element from its
current parent (Canvas) to a Stack Panel, the element is not visible in the
stack panel though it seems like it has been added Stack Panel as height
changes.

If I do not apply the animation and just run the code to dock the element
into the Stack Panel (DockIntoQueryStackPanel) then it all works fine

Heres a snippet of the code

private void animateToStackPanel(UIElement uiEl, int ii)
{
//apply animation to this venn circle
FrameworkElement ctl = uiEl as FrameworkElement;
Path path = uiEl as Path;
EllipseGeometry eG = path.Data as EllipseGeometry;
TranslateTransform tt = eG.Transform as TranslateTransform;

if (tt.X > 0)
{
// create movement animation
double endX =
(this.MainGrid.ColumnDefinitions[0].ActualWidth / SizeSlider.Value) +
(eG.RadiusX /
SizeSlider.Value);// -tt.X;// -(this.MainGrid.ColumnDefinitions[1].ActualWidth
/ 5);

double endY = (400 / SizeSlider.Value);//+ (eG.RadiusX /
SizeSlider.Value);// -tt.X;// -(this.MainGrid.ColumnDefinitions[1].ActualWidth
/ 5);
DoubleAnimation moveToStackX = new DoubleAnimation(tt.X,
endX, new Duration(TimeSpan.FromSeconds(ii)));
DoubleAnimation moveToStackY = new DoubleAnimation(tt.Y,
endY, new Duration(TimeSpan.FromSeconds(ii)));

String vName = "tt" + path.Name;

if (this.FindName(vName) == null)
{
RegisterName(vName, tt);
}
//setup X animation
Storyboard.SetTargetName(moveToStackX, vName);
Storyboard.SetTargetProperty(moveToStackX, new
PropertyPath(TranslateTransform.XProperty));

//setup Y animation
Storyboard.SetTargetName(moveToStackY, vName);
Storyboard.SetTargetProperty(moveToStackY, new
PropertyPath(TranslateTransform.YProperty));

myStoryBoard.Children.Add(moveToStackX);
myStoryBoard.Children.Add(moveToStackY);
myStoryBoard.Completed += new
EventHandler(myStoryBoard_Completed);
myStoryBoard.Begin(path);

}

}

void myStoryBoard_Completed(object sender, EventArgs e)
{
myStoryBoard.Children.Clear();

UIElement uiEl = (UIElement) elCollection.Pop();

//dropUIElement(el);
DockIntoQueryStackPanel(uiEl);

}

Any help appreciated?


Regards
Ranjit


Ranj

unread,
Apr 28, 2006, 4:01:34 AM4/28/06
to
Just to let you know, I resolved this by

Creating a new TranslationTransform settings its X and Y to 0 and applying
that to the EllipseGeometry.

For some unknown reason the X and Y of the TranslateTransform that were
animated do not get updated, even if I explicity reset the X and Y in code
to 0, there is no runtime error but just ignores the resetting to 0.

"Ranj" <rs...@removethis.hotmail.com> wrote in message
news:%231x3ozE...@TK2MSFTNGP04.phx.gbl...

Marcus

unread,
Apr 28, 2006, 8:13:37 AM4/28/06
to
After reading your reply, something crossed my mind...

In the way the framework evaluate a property`s value, an animation has
the precedence over everything else...

see:
http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/wpf_conceptual/html/1fbada8e-4867-4ed1-8d97-62c07dad7ebc.asp

There is a possibility that the property engine still evaluates the X
and Y of the transform according to the animation, instead of the
"local value"...

By setting a new transform on the object (with X and Y of 0), you might
be resetting this "weird" condition...

If somebody has more insight/explanations over this, I would be
interested in knowing the end of it...

Thanks

Marcus

viliescu

unread,
Apr 28, 2006, 12:21:02 PM4/28/06
to
Yes, it's because of the FillBehavior property for the Animations.
By default is HoldEnd which means that after the animations ends, the
property value is "frozen", you cannot change it by assignment. The solution
is to set FillBehavior to Stop.
--
Valentin Iliescu [MVP - Client Application Development]

Ranj

unread,
May 2, 2006, 6:13:40 AM5/2/06
to
Thanks for that its resolved the problem

Ranj

"viliescu" <vili...@discussions.microsoft.com> wrote in message
news:2909AE87-AD1F-451F...@microsoft.com...

0 new messages