I’ve been asked this ample times at my work place – how to implement a zoom in/out effect on any Silverlight Control.
So let us take an example:-
You have your contents inside a grid, typically named LayoutRoot, and you want to zoom it when Mouse is placed on it and get back to original shape when Mouse is removed from it.
This effect can be achieved by ScaleTransform which is a child of RenderTransform. This also means, elements who have RenderTransform as a child node can only implement this feature. So if you have any control which does not have RenderTransform as a child node – just encapsulate it in a Grid.
Your XAML code appears as:-[sourcecode language=’xml’]
Insert a story board in the UserControl:-[sourcecode language=’xml’]
The first animation is for ScaleX and the second animation is for ScaleY. You can change the sections in BLUE as per your need.
The code file appears as:[sourcecode language=’csharp’]
private void LayoutRoot_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
private void LayoutRoot_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
That’s as simple as that 🙂 Happy Zooming!