我根据这个好tutorial.创建了翻转动画。当我在Blend中运行动画时,没有问题,动画就会运行。但是在调试时,整个程序崩溃并出现错误"Cannot resolve TargetName bingMapGrid."
我发现很少有类似问题,但没有解决方案可以修复我的问题。
带动画元素的动画:
<Page.Resources>
<ResourceDictionary>
<Utils:ColorQualityConverter x:Key="ColorQualityConverter"/>
<localmain:PinTypeToStyleConverter x:Key="PinTypeToStyleConverter"/>
<Storyboard x:Name="FlipOpen">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="bingMapGrid">
<EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="90"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="mapSmall">
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="mapPanelSubGrid" Background="#FF323232" Grid.RowSpan="3" Height="768">
<Grid Margin="50,150,50,50">
<localmain:CzechMap x:Name="mapSmall" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" >
<localmain:CzechMap.Projection>
<PlaneProjection RotationY="-90"/>
</localmain:CzechMap.Projection>
</localmain:CzechMap>
<Grid x:Name="bingMapGrid">
<Grid.Projection>
<PlaneProjection/>
</Grid.Projection>
<bm:Map x:Name="infoMap" ZoomLevel="7.5" Credentials="AhzZ6z0JmgoOrR1vGQx3frGtarXsH36-JMp9Ba9zvNP16UXmIgXF84o2oysH0Sbg" >
<bm:Map.Center>
<bm:Location Latitude="49.75" Longitude="15.333"/>
</bm:Map.Center>
<bm:MapLayer Visibility="Visible">
<bm:MapItemsControl x:Name="StationsDetailPinLayer" ItemsSource="{Binding Pinmanager.Pins}">
<bm:MapItemsControl.ItemTemplate>
<DataTemplate>
<bm:Pushpin Tapped="Pushpin_Hold"
BorderBrush="{Binding SelectedBrush}"
Background="{Binding Station.Quality, Converter={StaticResource ColorQualityConverter}}"
Visibility="{Binding Visibility}"
Text="{Binding Station.Quality}">
<bm:MapLayer.Position>
<bm:Location Latitude="{Binding Location.Latitude}" Longitude="{Binding Location.Longitude}" />
</bm:MapLayer.Position>
</bm:Pushpin>
</DataTemplate>
</bm:MapItemsControl.ItemTemplate>
</bm:MapItemsControl>
</bm:MapLayer>
</bm:Map>
</Grid>
</Grid>
<AppBarButton x:Name="flipMapButton" HorizontalAlignment="Left" Icon="Map" Label="Detailní mapa" Margin="873,33,0,0" VerticalAlignment="Top" Tapped="flipMapButton_Tapped"/>
</Grid>
代码开始动画:
private void flipMapButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
FlipOpen.Begin();
}
提前感谢您提供可能的建议。
答案 0 :(得分:0)
好的,我在发布问题后立即找到解决方案。即使我不确定为什么,这也有效。
Resources.Add("FlipOpen", FlipOpen);
:
((Storyboard)Resources["FlipOpen"]).Begin();