Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只需要在按钮单击事件期间使用控件值更新绑定源对象。
但是由于我的顶层设置了数据上下文,所以只要控制值发生变化,它就会更新源对象......是否可以在该事件期间显式设置以更新它,只保持数据上下文不变?
文本框绑定:
<TextBox x:Name="myTextBox" Text="{Binding MyTextProperty, UpdateSourceTrigger=Explicit}"/>
按钮处理程序代码:
myTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();