很好玩的滚动效果

                 很好玩的滚动效果
                                  周银辉

role.PNG

你可以粘贴以下代码到XMLPad以查看动画效果:
<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>




posted @ 2007-04-23 21:34  周银辉  阅读(3487)  评论(7编辑  收藏  举报