【问题标题】:XAML transitions on Windows 8 IgnoredWindows 8 上的 XAML 转换已忽略
【发布时间】:2014-08-14 10:40:13
【问题描述】:

目前正在使用 Windows 8.1 和 XAML 转换。

我有一个可以在我的页面上进行翻译的网格。在网格内,我有一个要缩放的图像。 当我使用 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。

关于为什么会发生这种情况的任何想法?

【问题讨论】:

    标签: xaml windows-8 windows-8.1 expression-blend


    【解决方案1】:

    用于 WinRT 的 XAML 可能与 Silverlight 非常相似,但由于 Windows 应用商店应用程序可以在低端设备中运行,some restrictions have been introduced。在您的情况下,您正在尝试为子对象设置动画,这被认为是依赖动画。默认为WinRT doesn't execute dependent animations,除非在声明动画对象时指定EnableDependentAnimation="True"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      相关资源
      最近更新 更多