0

我有一个示例故事板,我想知道如何仅使用代码来实现,但我无法弄清楚。这是 WPF/XAML,任何指针将不胜感激。

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    AllowsTransparency="True"
        WindowStyle="None"
    Title="MainWindow" Height="350" Width="525" Background="Transparent" Topmost="True" WindowState="Maximized" ResizeMode="NoResize">
    <Canvas Name="canvas1">
        <Button Canvas.Left="145" Canvas.Top="155" Content="Button" Height="23" Name="Button1" Width="75">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.MouseEnter">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Button1" Storyboard.TargetProperty="Width" AutoReverse="true" RepeatBehavior="Forever">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="100"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:05" Value="300"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:10" Value="100"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimation 
                Storyboard.TargetName="Button1"
                Storyboard.TargetProperty="(Canvas.Left)"
                From="100" To="600" Duration="0:0:10" AutoReverse="true" RepeatBehavior="Forever"/>
                            <DoubleAnimation 
                Storyboard.TargetName="Button1"
                Storyboard.TargetProperty="(Canvas.Top)"
                From="100" To="600" Duration="0:0:10" AutoReverse="true" RepeatBehavior="Forever"/>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Button.Triggers>
        </Button>
    </Canvas>
</Window>
4

1 回答 1

1

你试过什么了?你有什么问题?

这个页面上有几个很好的例子:http ://www.galasoft.ch/mydotnet/articles/article-2006102701.aspx

于 2012-12-05T21:04:34.717 回答