Question : 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:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
 <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>


myRectangle is defined as:
1:
2:
3:
4:
5:
<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>

the code that sets the location and opacity of myRectangle:  
1:
2:
3:
4:
5:
Canvas.SetLeft(myRectangleAnimate, Canvas.GetLeft(Selected));
Canvas.SetTop(myRectangleAnimate, Canvas.GetTop(Selected));
myRectangleAnimate.Opacity = 1.0;
storyboardExpandContract.Begin();
the error occurs when I call the Begin().

Answer : Problem with Silverlight Animation -- cannot resolve targetname

Random Solutions  
 
programming4us programming4us