iamhx
iamhx

Reputation: 472

Windows 8.1 Store App: FadeInThemeAnimation when page loads

I'm trying to do a fade in page transition. The fade out transition works but when I try to do a fade in it doesn't seem to do anything, or perhaps is too fast.

My XAML Code:

<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>

For the EventHandler I tried Loaded but it didn't work.

Upvotes: 1

Views: 285

Answers (1)

O.O
O.O

Reputation: 11317

I would probably do this using the Behaviors SDK using ControlStoryboardAction

If you want to do it from code-behind use DoubleAnimation with the Opacity property instead of FadeInThemeAnimation.

XAML

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

Loaded event:

FadeInTransition.Begin();

Upvotes: 1

Related Questions