Skip to main content

Microsoft Silverlight

Answered Question Call Storyboard in Page_LoadRSS Feed

(0)

Silverlight Web Developer
Silverli...

Member

Member

74 points

308 Posts

Call Storyboard in Page_Load

I have created an animation that is has "border" as it target. Now if I want to play this animation in the Page_Load event I have tried the following but that gives compileerror when running the code.

It point to "s.Begin()" and says that

Cannot resolve TargetProperty

(UIElement.Render Transform).(TransformGroup.Children)[3].(TranslateTransform.X) on specified object.

 

	<UserControl.Resources>
		<Storyboard x:Name="Storyboard1">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-16"/>
				<EasingDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="-4"/>
				<EasingDoubleKeyFrame KeyTime="00:00:01" Value="-4"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</UserControl.Resources>


        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Storyboard s = this.Resources["Storyboard1"] as Storyboard;
            Storyboard.SetTarget(s, this);
            s.Begin();
        }
 

 

 

ccoombs
ccoombs

Contributor

Contributor

5146 points

757 Posts

Answered Question

Re: Call Storyboard in Page_Load

it looks like your storyboard is expecting a border.  you're passing "this" as the target, which is probably a usercontrol.  it also looks like your target is already set in xaml, so you shouldn't need the Storyboard.SetTarget call at all unless you're trying to dynamically change which border the storyboard affects.

Silverlight Web Developer
Silverli...

Member

Member

74 points

308 Posts

Re: Call Storyboard in Page_Load

You were right that line wasn´t needed. So now the page does open in the browser and the animation can be seen.

I thank you very much for your help.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities