动画项目WPF的下降

时间:2016-10-05 14:16:49

标签: wpf animation

请你帮我在我的WPF应用程序中从窗口的外部(从顶部)实现图像的下降(png)。最后它应该位于窗口的某个点。 Sw for English btw。

1 个答案:

答案 0 :(得分:1)

按原样运行:

<Window ...
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window15" Height="300" Width="300">

    <Window.Resources>
        <Storyboard x:Key="Sb1">
            <DoubleAnimation Storyboard.TargetName="Btn" Storyboard.TargetProperty="(Canvas.Top)" To="100" >
                <DoubleAnimation.EasingFunction>
                    <BounceEase Bounces="2" EasingMode="EaseOut" 
                                 Bounciness="2" />
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard Storyboard="{StaticResource Sb1}"/>
            </EventTrigger>
    </Window.Triggers>

    <Canvas Background="AliceBlue">
        <Button x:Name="Btn" Canvas.Top="-60" Canvas.Left="150"/>
    </Canvas>
</Window>

相应地更改To属性。