2013-04-15 36 views
2

我知道我可以用下面的代碼創建虛線。移動虛線用於裁剪

<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> 

有沒有什麼辦法讓虛線圍繞該區域移動以吸引注意力?

這是爲了裁剪圖像,以便很容易區分作物的線條。

+1

這就是所謂的[行軍螞蟻](http://en.wikipedia.org/wiki/Marching_ants)。 –

+0

@DrewNoakes謝謝。我從來沒有聽說過這個詞,但它非常有意義。 –

回答

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