locked
start on load RRS feed

  • Question

  • how do i get the SL animation to start on load instead of having to click a button. i forget how to do this.

    Sunday, June 21, 2009 8:35 AM

Answers

  •  One way

    <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Triggers>
                <EventTrigger RoutedEvent="Grid.Loaded">
                    <BeginStoryboard >
                        <Storyboard x:Name="MySB">
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Opacity"
                                            From="0" To="1" Duration="00:00:02"
                                            />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Grid.Triggers>

    </Grid>

     

    Another way as Galaad has said. but I prefer you do it in the loaded event instead directly on the constructor. Because in some rare situation you will find it gives you exeption because the animations target are not yet loaded if you run it from the constructor itself.

    Sunday, June 21, 2009 10:16 AM

All replies

  •  You have to put a method or directly begin the animation, in the method initialize_components.

    Look a this example : 

     

     public Page()
            {
                InitializeComponent();
                  my_animation.Begin();

    }

    Sunday, June 21, 2009 10:12 AM
  •  One way

    <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Triggers>
                <EventTrigger RoutedEvent="Grid.Loaded">
                    <BeginStoryboard >
                        <Storyboard x:Name="MySB">
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Opacity"
                                            From="0" To="1" Duration="00:00:02"
                                            />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Grid.Triggers>

    </Grid>

     

    Another way as Galaad has said. but I prefer you do it in the loaded event instead directly on the constructor. Because in some rare situation you will find it gives you exeption because the animations target are not yet loaded if you run it from the constructor itself.

    Sunday, June 21, 2009 10:16 AM