WPF 以编程方式删除边距动画

发布于 2024-08-07 20:35:42 字数 91 浏览 3 评论 0原文

如何删除动画故事板中堆栈面板两侧的边距,以便堆栈面板看起来已从后面的代码中移出?我需要在代码隐藏中执行此操作,因为我使用此动画的堆栈面板数量在运行时有所不同。谢谢:o)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-08-14 20:35:42

我不确定您是问如何在后面的代码中还是在动画 XAML 中设置边距值,所以我将在这两个方面都尝试一下。

在后面的代码中,您可以使用 DependencyProperty.SetValue 方法。例如: stackPanel.SetValue(MarginProperty, 0);

对于 XAML 动画,您可以添加厚度动画。例如:

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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文