How to create an animated message banner in WPF

Any pointers on how I can create one of these (usually yellow) pop-up animated banners used in web applications (e.g. FAQ for stackoverflow)?

+4
source share
1 answer

I really want to give the answer "use jQuery", but since this is WPF, I suppose something better is needed. To get started, I would determine where it will be in your xaml file. I would do it something like this:

<Window ...> <Grid> <Grid x:Name="DropDownBar" HorizontalAlignment="Stretch" Height="0"> <Rectangle Fill="Orange" /> </Grid> <!-- rest of your content here --> </Grid> </Window> 

To get that nice animation effect, something like:

 <Window.Resources> <Storyboard x:Key="LoadAnimation" Duration="0:0:3"> <DoubleAnimation Storyboard.TargetName="DropDownBar" Storyboard.TargetProperty="Height" From="0" To="30" /> </Storyboard> </Window.Resources> 

And then you just need to call it when the page loads:

 <Window.Triggers> <EventTrigger RoutedEvent="Window.Loaded"> <BeginStoryboard Storyboard="{StaticResource LoadAnimation}" /> </EventTrigger> </Window.Triggers> 

I typed this in this field, so there are several typos here and there. But basically, how I did it. Another alternative is fixing the height and moving the field from -high to 0.

+4
source

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


All Articles