Windows 8.1 商店应用:页面加载时的 FadeInThemeAnimation

Windows 8.1 Store App: FadeInThemeAnimation when page loads

我正在尝试淡入淡出页面过渡。淡出过渡有效,但是当我尝试淡入时它似乎没有做任何事情,或者可能太快了。

我的XAML代码:

<Page
x:Class="CYBOracleProject.Chapter1_1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CYBOracleProject"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
    <Storyboard x:Name="FadeInTransition">
        <FadeInThemeAnimation Storyboard.TargetName="StartPage1" />
    </Storyboard>
</Page.Resources>

<Grid x:Name="StartPage1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Image Source="Image/hallway.jpg" Stretch="Fill" />
</Grid>

对于 EventHandler,我尝试了 Loaded,但没有成功。

我可能会使用行为 SDK 使用 ControlStoryboardAction

如果您想从代码隐藏中使用 DoubleAnimationOpacity 属性 而不是 FadeInThemeAnimation.

XAML

<Storyboard x:Name="FadeInTransition">
        <DoubleAnimation Storyboard.TargetName="StartPage1"
                         Storyboard.TargetProperty="Opacity" From="0.0"
                         To="1.0" Duration="0:0:1" />
    </Storyboard>

加载事件:

FadeInTransition.Begin();