Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Call Storyboard in Page_Load
2 replies. Latest Post by Silverlight Web Developer on September 4, 2009.
(0)
Silverli...
Member
74 points
308 Posts
09-04-2009 3:58 PM |
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
Contributor
5146 points
757 Posts
09-04-2009 4:52 PM |
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.
09-04-2009 5:12 PM |
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.