Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello , i have this :

XML
<Storyboard x:Key="OnMouseLeave">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="InfExtraGrid" Storyboard.TargetProperty="(Grid.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-62"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>

            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="InfExtraCanvas">
    <BeginStoryboard Storyboard="{StaticResource OnMouseLeave}" />
</EventTrigger>


and i try this ,but not work :


C#
private void MoveBorder()
 {            try
     {
         DoubleAnimationUsingKeyFrames OnMouseLeave = new DoubleAnimationUsingKeyFrames();
         OnMouseLeave.BeginTime = TimeSpan.FromSeconds(0);
         OnMouseLeave.Duration = TimeSpan.FromSeconds(.5);
         OnMouseLeave.KeyFrames.Add(new SplineDoubleKeyFrame(-62, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0))));
         OnMouseLeave.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(.5))));

         Storyboard.SetTargetProperty(InfExtraGrid, new PropertyPath(TranslateTransform.YProperty));
         Storyboard strbStoryboard = new Storyboard();
         strbStoryboard.Children.Add(OnMouseLeave);
         strbStoryboard.Begin(this);
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Ex.Message);
     }
 }



please help me
Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-13 19:36pm    
OK, this is just a code dump. But what's the problem?
You have to start with what you want to achieve...
—SA
RDBurmon 26-Feb-13 1:58am    
Cesitar Ps : take some effort to explain your problem with some more word. It will have more clarity

1 solution

Hi,

I think you are setting the TargetProperty wrong and you aren't setting the TargetName of the storyboard.

Instead of:
C#
Storyboard.SetTargetProperty(InfExtraGrid, new PropertyPath(TranslateTransform.YProperty));


write:
C#
Storyboard.SetTargetName(OnMouseLeave, "InfExtraGrid");
Storyboard.SetTargetProperty(OnMouseLeave, new PropertyPath("(Grid.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)");


TargetName and TargetProperty are attached properties of the animation instance (from Storyboard), in this instance the OnMouseLeave object,
so you have to set these properties on the OnMouseLeave and not the InfExtraGrid object.

Hope this helps,

Thomas.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900