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.
Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/
mexican
Member
190 Points
1036 Posts
start on load
Jun 21, 2009 12:35 PM | LINK
how do i get the SL animation to start on load instead of having to click a button. i forget how to do this.
Galaad
Member
172 Points
103 Posts
Re: start on load
Jun 21, 2009 02:12 PM | LINK
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();
}
tanmoy.r
Contributor
4163 Points
796 Posts
Microsoft
Re: Re: start on load
Jun 21, 2009 02:16 PM | LINK
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.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/