2

Is there a way to create animation that would animate the control height, stretching it from 0 to original (preferred) size? That is, I have a control of height which depends on its text content, and I want to introduce an animation, that would roll it down.

H.B.
  • 166,899
  • 29
  • 327
  • 400
Marc Andreson
  • 3,405
  • 5
  • 35
  • 51
  • possible duplicate of [How to get desired height of WPF UI element with current height of 0?](http://stackoverflow.com/questions/5035174/how-to-get-desired-height-of-wpf-ui-element-with-current-height-of-0) – LPL Jul 24 '12 at 16:56
  • You are asking about Animations. You could start here: http://msdn.microsoft.com/en-us/library/ms752312.aspx. Can't give you any specific solutions since you don't provide enough details. – Kyeotic Jul 24 '12 at 17:48

2 Answers2

0

That is a bit tricky as the actual value is dynamic, so you cannot bind it animations as they need to be freezable. Also the value that represents this behavior (Double.NaN) cannot be used in non-discrete animations. Using fluid layout from Interactivity or some code behind you could do it, this question could serve as a reference. If you do not have fitting states already you will have to create your own and change the states manually to trigger the transitions.

Community
  • 1
  • 1
H.B.
  • 166,899
  • 29
  • 327
  • 400
0

When I looked into this in the past, the answer was to animate to the max height rather than the height. That way, you still end up with the height that it will be when it is expanded to fit content.

The problem, of course, is its harder to get a precise animation speed, since the control will naturally stop growing before the animation is done.

What I do, is I animate to the screen working height, and then on the animate finished event, I set the max height to positive infinity, which means there is no maximum height. This will make setting the duration a lot easier than if you were to animate from 0 to infinity.

Craig
  • 666
  • 7
  • 17