Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Storyboard Target name: Cannot resolve TargetName (Read 11815 times)
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Storyboard Target name: Cannot resolve TargetName
Jul 2nd, 2010 at 7:31am
Print Post  
Hi
I am trying to use Animation in the diagram lite samples.
I have defined a rectangle in generic.xaml as follows.

<Style TargetType="local:RectangleNode">
<Setter Property="Template">
   <Setter.Value>
               <ControlTemplate TargetType="local:RectangleNode">
                   <Canvas x:Name="Adorner" >
                       <StackPanel>
                           <ToolTipService.ToolTip>
                           <TextBlock Text="{TemplateBinding Title}" />
                       </ToolTipService.ToolTip>
                       <Border BorderBrush="Black" BorderThickness="2">
                           <StackPanel Orientation="Vertical">
                           
                                   <Rectangle x:Name="UpperRectangle" Width="25" Height="15" RadiusX="0" RadiusY="15" >
                                       <Rectangle.Fill>
                                           <SolidColorBrush Color="White" x:Name="rect1Color">
                                           </SolidColorBrush>
                                       </Rectangle.Fill>
                                   </Rectangle>
                       <Rectangle x:Name="LowerRectangle" Width="25" Height="15" RadiusX="0" RadiusY="30" Fill="LawnGreen">
                       </Rectangle>
                               </StackPanel>
                           </Border>
                       </StackPanel>
                   </Canvas>
               </ControlTemplate>
           </Setter.Value>
       </Setter>
    </Style>



And I have defined Storyboard in MainPage.xaml as follows:
     <StackPanel.Resources>
           <Storyboard x:Name="myStoryboard" AutoReverse="True" Duration="0:0:5">
               <ColorAnimation
                                       Storyboard.TargetProperty="Color"
                                       Storyboard.TargetName="rect1Color"
                                       From="White"
                                       To="Green"/>
           </Storyboard>
       </StackPanel.Resources>


When I run this , I got an exception:Cannot resolve TargetName rect1Color.
How to set the TargetName rect1Color defined in generic.xaml file here?


Thanks & Regards

Padma
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Storyboard Target name: Cannot resolve TargetN
Reply #1 - Jul 2nd, 2010 at 8:19am
Print Post  
How are you applying this animation to the node?
  
Back to top
 
IP Logged
 
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Re: Storyboard Target name: Cannot resolve TargetN
Reply #2 - Jul 2nd, 2010 at 8:55am
Print Post  
The rectangle node is filled and emptied with the specified color is what my intention here.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Storyboard Target name: Cannot resolve TargetN
Reply #3 - Jul 2nd, 2010 at 11:18am
Print Post  
Ok, but what code are you using to load and run the animation?
  
Back to top
 
IP Logged
 
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Re: Storyboard Target name: Cannot resolve TargetN
Reply #4 - Jul 2nd, 2010 at 11:29am
Print Post  
in one button click as follows:

private void btnAnimate_Click(object sender, RoutedEventArgs e)
{
         myStoryboard.Begin();
}


this is the way I am using it.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Storyboard Target name: Cannot resolve TargetN
Reply #5 - Jul 2nd, 2010 at 1:12pm
Print Post  
Animations must target a specific object, and not just a template definition. You could do the following:

Code
Select All
var node = (RectangleNode)diagram.Nodes[0];
Storyboard.SetTarget(myStoryboard.Children[0], node.rect1Color);
myStoryboard.Begin(); 



where rect1Color is exposed as a member of the node class. You can get a reference to it by overriding OnApplyTemplate:

Code
Select All
public class RectangleNode : ShapeNode
{
	...

	public override void OnApplyTemplate()
	{
		base.OnApplyTemplate();
		rect1Color = GetTemplateChild("rect1Color") as SolidColorBrush;
	}

	internal SolidColorBrush rect1Color;
	...
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint