开发者

WPF Remove Margin Animation Programmatically

开发者 https://www.devze.com 2022-12-09 03:05 出处:网络
How do I remove the margin开发者_Python百科s 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

How do I remove the margin开发者_Python百科s 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)


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>

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号