0

我正在开发一个存在巨大性能问题的 WPF 应用程序。当用户在屏幕之间移动时,应该有当前屏幕淡出和缩小的快速动画,而下一个屏幕淡入并从左侧滑入。这太混乱了。

现在,我遇到了EntranceThemeTransitionBehavior ( http://msdn.microsoft.com/EN-US/library/windows/apps/windows.ui.xaml.media.animation.entrancethemetransition.aspx ) 但有两件事我不知道不明白:

  • 这东西应该工作得更快吗?
  • 它可以用于非 Windows 商店应用程序吗?(只是普通的旧桌面应用程序)

在 WPF 中创建平滑淡入淡出 + 过渡的任何最佳实践/建议?

今天我用一个简单的故事板和不透明动画来做。这是一个例子:

当我在 2 个屏幕上并行运行时,淡入淡出真的很慢。

    <Grid x:Name="SlideShow" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <Grid.Resources>
            <Storyboard x:Key="Slide" RepeatBehavior="Forever" Timeline.DesiredFrameRate="30" >

                <DoubleAnimationUsingKeyFrames
                    BeginTime="00:00:7"
                    Storyboard.TargetName="Ad2"
                    Storyboard.TargetProperty="Opacity">

                    <SplineDoubleKeyFrame KeyTime="0:0:0.25" Value="1" />
                </DoubleAnimationUsingKeyFrames>


                <DoubleAnimationUsingKeyFrames
                    BeginTime="00:00:14.75"
                    Storyboard.TargetName="Ad3"
                    Storyboard.TargetProperty="Opacity">
                    <SplineDoubleKeyFrame KeyTime="0:0:0.25" Value="1" />
                </DoubleAnimationUsingKeyFrames>

                <DoubleAnimationUsingKeyFrames
                    BeginTime="00:00:24.25"
                    Storyboard.TargetName="Ad4"
                    Storyboard.TargetProperty="Opacity">
                    <SplineDoubleKeyFrame KeyTime="0:0:0.25" Value="1" />
                </DoubleAnimationUsingKeyFrames>


                <DoubleAnimationUsingKeyFrames
                    BeginTime="00:00:32.75"
                    Storyboard.TargetName="Ad2"
                    Storyboard.TargetProperty="Opacity">
                    <SplineDoubleKeyFrame KeyTime="0:0:0.25" Value="0" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames
                    BeginTime="00:00:32.75"
                    Storyboard.TargetName="Ad3"
                    Storyboard.TargetProperty="Opacity">
                    <SplineDoubleKeyFrame KeyTime="0:0:0.25" Value="0" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames
                    BeginTime="00:00:32.75"
                    Storyboard.TargetName="Ad4"
                    Storyboard.TargetProperty="Opacity">
                    <SplineDoubleKeyFrame KeyTime="0:0:0.25" Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </Grid.Resources>

        <Grid.Triggers>
            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard Storyboard="{StaticResource Slide}" />
            </EventTrigger>
        </Grid.Triggers>

        <Image  Source="/MyApp;component/Resources/Images/SecondScreen/1.png"  Name="Ad1" Opacity="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        <Image  Source="/MyApp;component/Resources/Images/SecondScreen/2.png"  Name="Ad2" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        <Image  Source="/MyApp;component/Resources/Images/SecondScreen/3.png"  Name="Ad3" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        <Image  Source="/MyApp;component/Resources/Images/SecondScreen/4.png"  Name="Ad4" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
4

0 回答 0