Fazer uma PerguntaFazer uma Pergunta
 

PerguntaAnimating A Polygon?

  • quarta-feira, 17 de janeiro de 2007 18:47moonwalkercss Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Hi

    I have a polygon made up of a PointCollection...Is there any way to animate the points as a group?  I tried to name the points and animated them individually, but naming points is not allowed.

Todas as Respostas

  • quarta-feira, 17 de janeiro de 2007 19:17Anthony Hodsdon - MSFT Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    You can either dot down to the points using TargetPath, or convert the Polygon over to a Path containing a PathGeometry:

    <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="
    http://schemas.microsoft.com/winfx/2006/xaml">

        <Canvas.Triggers>
          <EventTrigger RoutedEvent="Canvas.Loaded">
    <BeginStoryboard>
              <Storyboard>
                <PointAnimation
       By="-20,-20"
       Duration="0:0:2"
       RepeatBehavior="Forever"
       AutoReverse="True"
       Storyboard.TargetName="figure1"
       Storyboard.TargetProperty="StartPoint"/>
                <PointAnimation
       By="40,40"
       Duration="0:0:2"
       RepeatBehavior="Forever"
       AutoReverse="True"
       Storyboard.TargetName="segment1"
       Storyboard.TargetProperty="Point"/>
      <PointAnimation
       By="50,40"
       Duration="0:0:2"
       RepeatBehavior="Forever"
       AutoReverse="True"
       Storyboard.TargetName="segment2"
       Storyboard.TargetProperty="Point"/>
                  <PointAnimation
       By="-20,30"
       Duration="0:0:2"
       RepeatBehavior="Forever"
       AutoReverse="True"
       Storyboard.TargetName="segment3"
       Storyboard.TargetProperty="Point"/>
       
           </Storyboard>
    </BeginStoryboard>
     </EventTrigger>
        </Canvas.Triggers>

    <Path Name="path" Fill="#20000000">
      <Path.Data>
        <PathGeometry>
          <PathGeometry.Figures>
            <PathFigureCollection>
              <PathFigure x:Name="figure1" IsFilled="True" StartPoint="10, 100">
                <PathFigure.Segments>
                  <PathSegmentCollection>
                       <LineSegment x:Name="segment1" Point="20, 20" />   
                       <LineSegment x:Name="segment2" Point="90, 100" />
                       <LineSegment x:Name="segment3" Point="90, 200" />
                  </PathSegmentCollection>
                </PathFigure.Segments>
              </PathFigure>
            </PathFigureCollection>
          </PathGeometry.Figures>
        </PathGeometry>
      </Path.Data>
    </Path>
    </Canvas>