Binding Storyboard value to parent host property
-
Thursday, September 13, 2012 9:59 AM
Dear all,
I have the follwoing storyboard :
<Storyboard x:Key="OpenInfoTitle"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="_InfoPanel"> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="250"/> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="350"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="_InfoPanel"> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="250"/> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="300"/> </DoubleAnimationUsingKeyFrames> </Storyboard>I need to bind the Value property of the EasingDoubleKeyFrame to the ActualWidth of the parent host.
Does this will work using binding Realtive source and specify ancestor type ?I have try but seems it is not working
thanks for help
Serge
Your knowledge is enhanced by that of others.
All Replies
-
Thursday, September 13, 2012 10:25 AM
Should work.
Is your eventtrigger right?
I think you'd need routedevent valuechanged.
Next thing to check is the relativesource is right, which can be tricky.
- Marked As Answer by Serge Calderara Thursday, September 13, 2012 11:46 AM
- Unmarked As Answer by Serge Calderara Thursday, September 13, 2012 1:38 PM
-
Thursday, September 13, 2012 1:40 PM
Thnaks for your reply.
The reason I find it is not working is that I need to have the Value 350 and 300 from code as it should come from a dynamic value.So how can I do the above animation in code behind ?
regards
Your knowledge is enhanced by that of others.
-
Thursday, September 13, 2012 3:21 PM
I'm not sure how the actualwidth comes into it then.
Say you bind the width of the control to a property in the viewmodel holds those values.
Then animate to the actualwidth.
Will that do what you want?
Or do you mean you're setting the width of the container to those?
-
Thursday, September 13, 2012 3:41 PM
I need to change dynamically from code the value of the keyfame .
So I am simply trying to write the storyboard that I am in XAML in code behind but I miss something.
thnaks for help
Your knowledge is enhanced by that of others.
- Edited by Serge Calderara Thursday, September 13, 2012 3:53 PM
-
Friday, September 14, 2012 8:19 AMModerator
Hi Serge,
refer to below code behind animation:
DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame ad = new EasingDoubleKeyFrame(); ad.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0,0,1)); ad.Value = ActualWidth; EasingDoubleKeyFrame ad2 = new EasingDoubleKeyFrame(); ad2.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 1)); ad2.Value = ActualWidth; DoubleAnimationUsingKeyFrames da2 = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame ad3 = new EasingDoubleKeyFrame(); ad3.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 1)); ad3.Value = ActualHeight; EasingDoubleKeyFrame ad4 = new EasingDoubleKeyFrame(); ad4.KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 1)); ad4.Value = ActualHeight; da.KeyFrames.Add(ad); da.KeyFrames.Add(ad2); da2.KeyFrames.Add(ad3); da2.KeyFrames.Add(ad4);
Best regards,
Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked As Answer by Serge Calderara Saturday, September 15, 2012 4:53 PM
-
Friday, September 14, 2012 9:12 AMCan you not just bind the values to something in your viewmodel and change that?

