2011-01-19 14 views
2

私は空想的な点滅アイコンを作って、GeometryDrawingのブラシをアニメーションしようとしていて、これを行う方法を理解できません。出来ますか?ここでGeometryDrawingのプロパティをアニメーション化するにはどうすればよいですか?

は、いくつかの基本XAMLはそれのためColorAnimationを使用

<Window.Resources> 
    <GeometryDrawing x:Key="_geometryTest" Brush="#FF6C897B" Geometry="F1 M 66,188L 194,60L 322,188L 250.889,188L 250.889,348L 137.111,348L 137.111,188L 66,188 Z "> 
     <GeometryDrawing.Pen> 
      <Pen LineJoin="Round" Brush="#FF000000"/> 
     </GeometryDrawing.Pen>  
    </GeometryDrawing> 
</Window.Resources> 
<Grid> 
    <Image> 
     <Image.Source> 
      <DrawingImage x:Name="_myImage" Drawing="{StaticResource _geometryTest}"/> 
     </Image.Source> 
    </Image> 
    </Grid> 

答えて

2

です。 Windowは、ネストされたTargetPropertyの構文は、私は感謝探していたものだった

<Window.Resources> 
    <GeometryDrawing x:Key="_geometryTest" 
        Brush="#FF6C897B" 
        Geometry="F1 M 66,188L 194,60L 322,188L 250.889,188L 250.889,348L 137.111,348L 137.111,188L 66,188 Z"> 
     <GeometryDrawing.Pen> 
      <Pen LineJoin="Round" Brush="#FF000000"/> 
     </GeometryDrawing.Pen> 
    </GeometryDrawing> 
</Window.Resources> 
<Window.Triggers> 
    <EventTrigger RoutedEvent="Window.Loaded"> 
     <BeginStoryboard> 
      <Storyboard> 
       <ColorAnimation Storyboard.TargetName="myImage" 
           Storyboard.TargetProperty="(Image.Source).(DrawingImage.Drawing).(GeometryDrawing.Brush).(SolidColorBrush.Color)" 
           To="Red" 
           Duration="0:0:0.5" 
           AutoReverse="True" 
           RepeatBehavior="Forever" /> 
      </Storyboard> 
     </BeginStoryboard> 
    </EventTrigger> 
</Window.Triggers> 
<Grid> 
    <Image Name="myImage"> 
     <Image.Source> 
      <DrawingImage x:Name="_myImage" Drawing="{StaticResource _geometryTest}"/> 
     </Image.Source> 
    </Image> 
</Grid> 
+0

にロードされたときに、この例では、アニメーションを開始します! – kbeal2k

関連する問題