当面板的宽度已绑定到情节提要时如何更改面板宽度

发布于 2025-01-01 13:11:53 字数 149 浏览 1 评论 0 原文

我在设计时应用了故事板动画来更改堆栈面板宽度。但是,当我在单击按钮时显式更改同一控件的宽度时,其宽度没有变化。 当我在设计时不应用任何故事板时,宽度更改就可以了。

有没有什么方法可以从面板控件中删除故事板绑定,并在我想要单击按钮时应用相同的绑定。

谢谢

I have applied a storyboard animation at design time to change a stackpanel width. But when I explicitly change same control's width on a button click, then there is no change in its width.
When I do not apply any storyBoard at design time, then width change works.

Is there any way to remove storyboard binding from a panel control and apply same whenever I want on a button click.

thanks

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

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

发布评论

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

评论(1

嗼ふ静 2025-01-08 13:11:53

DependencyProperty 对来自不同源且具有不同优先级的更改请求做出反应。您可以在依赖属性值优先级一文中了解更多信息在 MSDN 上。在您的情况下,从 Animation 对象发送的对 StackPanel.Width DependencyProperty 的更改请求会覆盖 Trigger< 中所做的任何更改/code> Setter 对象。

最简单的方法是在更改 StackPanel.Width 之前在 Button.Click 处理程序中暂停或停止 Storyboard。请参阅这篇文章,其中涉及类似的情况。您可以在 MSDN Storyboard.Pause Method 文章中找到更多信息。

DependencyPropertys react to change requests from different sources with different precedences. You can find out more in the Dependency Property Value Precedence article on MSDN. In your situation, the change requests to the StackPanel.Width DependencyProperty sent from the Animation object override any changes made in a Trigger Setter object.

The easiest thing to do is to pause or stop the Storyboard in the Button.Click handler before you change the StackPanel.Width. See this post which deals with a similar situation. You can find further information in the MSDN Storyboard.Pause Method article.

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