Animating ViewBox for WPF

ViewBox (or more accurately Viewbox for those pedants playing along at home) is a nifty little convenience wrapper around scale transformations that is typically used to scale up content to fit a given area. Recently I wanted a Viewbox that animated on resize, and thus the AnimatingViewBox was born.

Essentially it allows you to specify an easing function for the resize, and a duration for the X and Y.

<Samples:AnimatingViewBox Grid.Row="1" Margin="20" 
         ResizeXDuration="0:0:0.5" ResizeYDuration="0:0:1">
    <Samples:AnimatingViewBox.EasingFunction>
        <BounceEase Bounces="1" Bounciness="0.6" />
    </Samples:AnimatingViewBox.EasingFunction>
    <TextBox Text="Test" AcceptsReturn="True" BorderThickness="0" />
</Samples:AnimatingViewBox>

Or you can just use it as a drop-in replacement for the Viewbox, in which case it defaults to about 300ms for the X and Y resize, and a BackEase.

The source code and sample application are available on bitbucket as part of my learnwpf samples project.

Here is the obligatory video

Comments

alvinashcraft.com
Pingback from alvinashcraft.com

Dew Drop – August 2, 2011 | Alvin Ashcraft's Morning Dew

2/08/2011 12:38:21 PM
mas-tool.com
Pingback from mas-tool.com

Animating ViewBox for WPF « Mas-Tool's Favorites

4/08/2011 6:18:43 PM
sjrluxuria
Thanks for useful info! Really good post!
4/08/2011 7:42:46 PM
Microsoft Weblogs
Windows Client Developer Roundup 078 for 8/15/2011

The Windows Client Developer Roundup aggregates information of interest to Windows Client Developers

15/08/2011 7:50:22 PM