Animated transitions in WPF

Posted by arconaut on Stack Overflow See other posts from Stack Overflow or by arconaut
Published on 2009-06-06T23:03:19Z Indexed on 2010/04/30 6:47 UTC
Read the original article Hit count: 293

Filed under:
|

I can't figure out what I'm missing here.

Here's the problem:
Consider a (Control|Data)Template with a Trigger that switches visibility of some inner UI elements. E.g. show a TextBlock when IsReadOnly==true and show a TextBox when IsReadOnly==false.

Everything is perfect if you do this without animation - one or two setters would do the job. But what if you want a fancy animation? Then you would specify which animations to start in EnterActions and ExitActions.

But the problem is what exactly the animations should do? Modifying width/height seems really ugly, because fixed sizes in WPF are almost always a wrong way to go and also it's absolutely unflexible.

So far, the best I've come up with is modifying MaxHeight/MaxWidth to some extent, this gives just a little more flexibility but still seems brutal.

How do you tell WPF to animate Width/Height of an element from 0 to "as much as needed"?

UPD: Currently I do animate Opacity and RenderTransform, and it works. It's just that sometimes I'd like to see animations where elements slide around without transformation. This is not a critical question, but a quite interesting one for me.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about animation