Search code examples
c#wpfmarching-ants

Moving Dotted line for cropping


I know that I can create the dashed line with the following code.

<Window x:Class="MarchingAnts.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Rectangle x:Name="RubberBand" Stroke="Black" StrokeDashArray="10"></Rectangle>
    </Grid>
</Window>

Is there any way to make the dashed line move around the area to draw attention to it?

This is for cropping an image, so that it is easy to distinguish the lines of the crop.


Solution

  • <Storyboard x:Key="BorderAnimation">
        <DoubleAnimation To="200" Duration="0:0:10" RepeatBehavior="Forever" By="2" 
                         Storyboard.TargetProperty="StrokeDashOffset" Storyboard.TargetName="Border"/>
    </Storyboard>