Dash Animation

|

I seldom use WPF's animation capabilities, mostly because I believe the overuse of animations doesn't do any good to user experience, but animtions can be cool if you do it and use it appropriately, this bit of XAML snippet shown below just comes into my imagination, it doesn't serve any practical purpose, but is fun to play with:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         
Title="Dash Animation">
    <
Viewbox Margin="30">
        <
Rectangle
           Name="ellipse"
           Width="600"
           Height="600"
           Fill="Green"
           Stroke="Red"
           StrokeThickness="120"
           StrokeDashArray="0,2"
           StrokeDashOffset="0"
           StrokeDashCap="Round">
            <
Rectangle.Triggers>
                <
EventTrigger RoutedEvent="FrameworkElement.Loaded">
                    <
BeginStoryboard>
                        <
Storyboard>
                            <
DoubleAnimation
                               To="20"
                               Duration="0:0:5"
                               RepeatBehavior="Forever"
                               By="2"
                               Storyboard.TargetProperty="StrokeDashOffset" />
                        </
Storyboard>
                    </
BeginStoryboard>
                </
EventTrigger>
            </
Rectangle.Triggers>
        </
Rectangle>
    </
Viewbox>
</
Page>

2 comments:

Unknown said...
This comment has been removed by the author.
Timo Boehme said...

Great. I've looked for this issue. Thanks