Automatic Smooth Resize Transitions - A Problem with Storyboards
I have been trying for some time to create a class/series of classes that, upon detecting a resize in a related object, attempts to halt the resize of the object and create a smooth resize animation for it. However, I have always had a problem with the objects 'flickering' on the screen for a second at the target size before the animation kicks in.
Long story short, after some serious debugging and self-doubt, I am under the impression that calling Storyboard.Begin()
does not affect the target value until the next开发者_开发知识库 clock tick. I presume that this has something to do with Storyboard.Seek()
not occuring until the next clock tick. (See the MSDN Reference). And as such, the object adopts its new height for a single frame before the animation kicks in which pulls it back to the starting height.
I have spent a long time trying to get this working because it's not nearly as simple as it seems. I can't set FrameworkElement.Height
to the e.PreviousSize.Height
in a FrameworkElement.SizeChanged
event handler, because that affects the 'true' height of the object. As an example of why this doesn't work, is if something changes the 'true' height of the object while the animation is playing, then re-setting FrameworkElement.Height
to the target height that was collected when the animation began could set it as an incorrect, out-dated value.
There's more things I've tried, and I'm sure they'll come up as answers arrive, but any ideas you have will be very much appreciated.
You'd probably have better luck by creating a layout container that handles the resize of the child objects, something like Robby Ingebretsen's Animated Panel.
精彩评论