views:

446

answers:

1

How do I remove the margins of two sides of a stackpanel in an animation storyboard so it looks like the stackpanel has moved from the code behind? I need to do it in the code-behind because the number of stackpanels i use this animation on differs at runtime. Thanks :o)

A: 

I am not sure if you're asking how to set the margin value in the code behind or in the animation XAML, so I'll take a shot at both.

In the code behind you can use the DependencyProperty.SetValue method. For example: stackPanel.SetValue(MarginProperty, 0);

For the XAML animation you can add a thickness animation. For example: <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="stackPanel" Storyboard.TargetProperty="Margin"> <SplineThicknessKeyFrame KeyTime="00:00:00.025" Value="4,4,2,2"/> </ThicknessAnimationUsingKeyFrames>

Lee Roth