目前正在使用Windows 8.1和XAML Transitions。
我有一个可翻译在我页面上的网格。在网格内部,我有一个我想要缩放的图像。 当我使用Blend设置动画时,一切都很好但是一旦部署,图像上的缩放动画就不会被操作,就像网格停止强制其子项忽略它们的过渡一样。
相同的XAML代码在Windows Phone上按预期工作,但在Windows 8.1上没有。
以下是一些示例代码:
<Page.Resources>
<ResourceDictionary>
<Storyboard x:Name="MainStoryboard">
<DoubleAnimationUsingKeyFrames x:Name="PanelOut" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="Panel1">
<EasingDoubleKeyFrame x:Name="PanelOutInitial" KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame x:Name="PanelOutKeyFrame" KeyTime="0:0:3" Value="-648">
<EasingDoubleKeyFrame.EasingFunction>
<QuinticEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames x:Name="PanelIn" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="Panel2">
<EasingDoubleKeyFrame x:Name="PanelInInitial" KeyTime="0" Value="648"/>
<EasingDoubleKeyFrame x:Name="PanelInKeyFrame" KeyTime="0:0:3" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<QuinticEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="Image2">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:3" Value="2"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="Image2">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:3" Value="2"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="LayoutRoot" Tapped="LayoutRoot_Tapped" Background="DarkGray">
<Grid
x:Name="Panel1"
Background="{StaticResource StoryBackgroundBrush}"
RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<CompositeTransform/>
</Grid.RenderTransform>
<Grid.CacheMode>
<BitmapCache></BitmapCache>
</Grid.CacheMode>
<Grid>
<Image x:Name="Image1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="/uicontent/images/AttractLoop/imaging3.jpg" Stretch="UniformToFill" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
</Image>
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Share photos easily." VerticalAlignment="Top" Margin="48,48,0,0" FontSize="68" FontFamily="Segoe UI" Foreground="#FFDA3B01"/>
</Grid>
</Grid>
<Grid
x:Name="Panel2"
Background="{StaticResource OneDriveBackgroundBrush}"
RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<CompositeTransform x:Name="Trans" TranslateY="800"/>
</Grid.RenderTransform>
<Grid.CacheMode>
<BitmapCache></BitmapCache>
</Grid.CacheMode>
<Grid>
<Image x:Name="Image2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="/uicontent/images/AttractLoop/imaging1.jpg" Stretch="UniformToFill">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
</Image>
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Tap to begin." VerticalAlignment="Top" Margin="48,48,0,0" FontSize="68" FontFamily="Segoe UI" Foreground="#FFDA3B01"/>
</Grid>
</Grid>
</Grid>
有趣的是,当我尝试在Blend中编辑过渡时,缩放动画滑块总是快速回到0,就像有错误一样。
有关为何发生这种情况的任何想法?
答案 0 :(得分:2)
WinRT的XAML可能与Silverlight非常相似,但由于Windows应用商店应用程序可以在低端设备中运行,some restrictions have been introduced。在您的情况下,您尝试为子对象设置动画,这被视为依赖动画。默认情况下为WinRT doesn't execute dependent animations,除非您在声明动画对象时指定EnableDependentAnimation="True"
。