How to activate management in WPF?

I saw an example of a WPF program that I cannot find. In this example, when I press a button, another button starts to grow and contract. While I can do other things with the form. How to do it?

+4
source share
2 answers

Below you will find a very simple example of increasing the height of the button \ width when the button is pressed and compressed when the mouse leaves the control. Animation in WPF is done using StoryBoards. Storyboards are commonly found in EventTriggers and can be stored in management resources, windows, pages, or applications. Below is a sample along with some resources:

<Window x:Class="WPFFeatureSample_Application.AnimationWindowSample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="AnimationWindowSample" Height="300" Width="300"> <Grid> <Button Content="Sample" Width="50" Height="50"> <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation To="200" Storyboard.TargetProperty="Width"></DoubleAnimation> <DoubleAnimation To="200" Storyboard.TargetProperty="Height"></DoubleAnimation> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="MouseLeave"> <BeginStoryboard> <Storyboard> <DoubleAnimation To="50" Storyboard.TargetProperty="Width"></DoubleAnimation> <DoubleAnimation To="50" Storyboard.TargetProperty="Height"></DoubleAnimation> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> </Grid> 

Literature:

http://msdn.microsoft.com/en-us/library/ms742868.aspx

http://windowsclient.net/learn/

+9
source

You can animate controls in WPF using storyboards.

Check out Animation Overview on MSDN.

+1
source

Source: https://habr.com/ru/post/1390048/


All Articles