silverlight动画

来源:互联网 发布:r软件怎么用 编辑:程序博客网 时间:2024/04/28 18:24
 <Window
    xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
    xml:lang=
"zh-CN"
    xmlns:System=
"clr-namespace:System;assembly=mscorlib"
    x:Name=
"Window"
    Title=
"Window1"
    Width=
"640" Height="480">

    <Window.Resources>
        <Storyboard x:Key="Timeline1" RepeatBehavior="Forever">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
Storyboard.TargetName=
"rectangle" Storyboard.TargetProperty="(Shape.StrokeDashOffset)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="100"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="rectangle">
            <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
        </EventTrigger>
    </Window.Triggers>

    <Grid x:Name="LayoutRoot">
        <Grid Margin="125,0,291,68" VerticalAlignment="Bottom" Height="113">
            <Rectangle Fill="{x:Null}" Stroke="#FF000000" StrokeDashCap="Square" 
StrokeDashOffset=
"100" StrokeEndLineCap="Square" StrokeLineJoin="Miter" 
StrokeStartLineCap=
"Flat" StrokeThickness="5" x:Name="rectangle">
                <Rectangle.StrokeDashArray>
                    <System:Double>0</System:Double>
                    <System:Double>2</System:Double>
                </Rectangle.StrokeDashArray>
            </Rectangle>
            <Button Margin="2,2,2,2" Content="Button"/>
        </Grid>
    </Grid>
</Window>
原创粉丝点击