Link to home
Start Free TrialLog in
Avatar of VoodooFrog
VoodooFrogFlag for United States of America

asked on

Problem with Silverlight Animation -- cannot resolve targetname

I created a simple animation via ExpressionBlend to give a confirmation of a user control being clicked.  the UserControl that I made is simply called MyRectangle and does not do much right now.  

What I thought would be the simplest way to create a click confirmation is to create a new myRectangleObject -- called myRectangleAnimate which starts of with an opacity of 0.  When the user clicks on the object I move myRectangleAnimate to the same position as the clicked object, set the opacity to 1.0 and then run the Storyboard that I created in blend.  

When I call the Storyboard.Begin() method I get the following error:
"Cannot resolve TargetName myRectangleAnimate"

myRectangleAnimate is defined in the XAML of the MainPage.xaml and starts off with the opacity at 0.

Here is the storyboard:
 <Canvas x:Name="myCanvas"  Width="731" Height="395">
                <Canvas.Resources>
<Storyboard x:Name="storyboardExpandContract" Completed="storyboardExpandContract_Completed">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="myRectangleAnimate">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="2"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="myRectangleAnimate">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="2"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
</Canvas.Resources>

Open in new window


myRectangle is defined as:
<local:myRectangle x:Name="myRectangleAnimate" Canvas.Left="589" Canvas.Top="232" RenderTransformOrigin="0.5,0.5" Opacity="0">
            		<local:myRectangle.RenderTransform>
            			<CompositeTransform/>
            		</local:myRectangle.RenderTransform>
            	</local:myRectangle>

Open in new window

the code that sets the location and opacity of myRectangle:  
Canvas.SetLeft(myRectangleAnimate, Canvas.GetLeft(Selected));
Canvas.SetTop(myRectangleAnimate, Canvas.GetTop(Selected));
myRectangleAnimate.Opacity = 1.0;
storyboardExpandContract.Begin();

Open in new window

the error occurs when I call the Begin().
Avatar of VoodooFrog
VoodooFrog
Flag of United States of America image

ASKER

for reference -- the storyboard was originally put into <UserControl.REsources> at the very top of the xaml file, I moved it into the Canvas.Resources while trying to debug this.  
Avatar of Shahan Ayyub
See the accepted solution in the below link may be it will helpful to upto some extent:

http://forums.silverlight.net/forums/p/15490/51226.aspx#51226
I don't think that solution is applicable here --  I have tried it in both scopes.  
ASKER CERTIFIED SOLUTION
Avatar of Shahan Ayyub
Shahan Ayyub
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial