无法解析TargetName..通过Blend制作的动画实际上不起作用
本文关键字:动画 实际上 不起作用 Blend TargetName 通过 | 更新日期: 2023-09-27 18:29:27
我已经根据这个不错的教程创建了翻转动画。当我在"混合"中运行动画时,没有问题,动画也会运行。但在调试过程中,整个程序崩溃,出现错误"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();
}
提前感谢您的建议。
好的,我在发布问题后就找到了解决方案。这是有效的,即使我不确定为什么。
Resources.Add("FlipOpen", FlipOpen);
:
((Storyboard)Resources["FlipOpen"]).Begin();