当面板的宽度已绑定到情节提要时如何更改面板宽度
我在设计时应用了故事板动画来更改堆栈面板宽度。但是,当我在单击按钮时显式更改同一控件的宽度时,其宽度没有变化。 当我在设计时不应用任何故事板时,宽度更改就可以了。
有没有什么方法可以从面板控件中删除故事板绑定,并在我想要单击按钮时应用相同的绑定。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DependencyProperty
对来自不同源且具有不同优先级的更改请求做出反应。您可以在依赖属性值优先级一文中了解更多信息在 MSDN 上。在您的情况下,从Animation
对象发送的对StackPanel.Width
DependencyProperty
的更改请求会覆盖Trigger< 中所做的任何更改/code>
Setter
对象。最简单的方法是在更改
StackPanel.Width
之前在Button.Click
处理程序中暂停或停止Storyboard
。请参阅这篇文章,其中涉及类似的情况。您可以在 MSDN Storyboard.Pause Method 文章中找到更多信息。DependencyProperty
s 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 theStackPanel.Width
DependencyProperty
sent from theAnimation
object override any changes made in aTrigger
Setter
object.The easiest thing to do is to pause or stop the
Storyboard
in theButton.Click
handler before you change theStackPanel.Width
. See this post which deals with a similar situation. You can find further information in the MSDN Storyboard.Pause Method article.