private void ResizeWindow(double width, double height)
{
Duration duration = TimeSpan.FromSeconds(2);
DoubleAnimation widthAnimation = new DoubleAnimation();
widthAnimation.To = width;
widthAnimation.Duration = duration;
DoubleAnimation heightAnimation = new DoubleAnimation();
heightAnimation.To = height;
heightAnimation.Duration = duration;
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(widthAnimation);
storyboard.Children.Add(heightAnimation);
Storyboard.SetTarget(widthAnimation, this);
Storyboard.SetTarget(heightAnimation, this);
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Window.WidthProperty));
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(Window.HeightProperty));
storyboard.Begin();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ResizeWindow(640, 360);
}