【发布时间】:2013-10-23 17:52:26
【问题描述】:
我在 WPF 中有一个 ContentControl,其中包含一些输入控件,例如 TextBoxes 和 ComboBoxes。
这些控件中的每一个都通过UpdateSourceTrigger=Explicit 数据绑定到 ViewModel 中的给定属性。
当我点击一些“提交”按钮时,我想遍历FormularioPaciente 的每个具有绑定的子级,并调用UpdateSource:
private void btnSalvarEditarPaciente_Click(object sender, System.Windows.RoutedEventArgs e) {
foreach (var childControl in LogicalTreeHelper.GetChildren(FormularioPaciente)) {
// what should I do now?
// I would really like to "auto-find" everything that should be updated...
}
}
【问题讨论】:
-
stackoverflow.com/questions/3586870/…这个答案可以帮你找到所有的绑定
-
@nit 我认为它是完全重复的,但事实并非如此,因为它告诉了如何以
BindingBase查找绑定,但没有告诉如何从中调用BindingExpression.UpdateSource。 .. -
嗯..我已经为你更新了答案..希望对你有帮助
标签: wpf data-binding visualtreehelper updatesourcetrigger