使用Pushpins时,我的动画中会发生未处理的异常

时间:2011-12-01 17:41:24

标签: silverlight windows-phone-7

我整体上遇到动画问题 - 我只是不明白:)

这里我想要实现的是使用一些漂亮的图像在地图中显示我自己的位置,我一直在尝试动画它。这个例子只是把它翻过来。 Point不是什么样的动画,而是整体运动 - 现在我得到了未处理的异常而没有任何好的信息。

<my:MapItemsControl x:Name="mapItemsControl" ItemsSource="{Binding PushpinsImage}">
  <my:MapItemsControl.ItemTemplate>
    <DataTemplate>
      <my:Pushpin x:Name="PushpinImage1"
                  Style="{StaticResource PushpinStyle3}"
                  Location="{Binding PushpinLocation}"
                  MouseLeftButtonUp="Pushpin_MouseLeftButtonUp">
        <Image x:Name="PointMe" Source="{Binding PushpinImage}">
          <Image.Triggers>
            <EventTrigger RoutedEvent="Image.Loaded">
              <BeginStoryboard>
                <Storyboard>
                  <DoubleAnimation Duration="0:0:1" To="180" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="PointMe" RepeatBehavior="Forever" />
                </Storyboard>
              </BeginStoryboard>                                                    
            </EventTrigger>
          </Image.Triggers>
        </Image>    
      </my:Pushpin>
    </DataTemplate>
  </my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>

这是来自appl.xaml的pushpintstyle3样式:

我的代码出了什么问题。总的来说,我在动画方面遇到了很多问题。

1 个答案:

答案 0 :(得分:2)

正如MSDN所说,Projection属性值默认为null。因此,您应该添加一些默认投影:

<Image x:Name="PointMe" Source="{Binding PushpinImage}">
  <Image.Projection>
    <PlaneProjection />
  </Image.Projection>
...
</Image>