如何使用 WPF MVVM 回滚组合框的选定 SelectedValue [英] How to rollback selected SelectedValue of the combo box using WPF MVVM
本文介绍了如何使用 WPF MVVM 回滚组合框的选定 SelectedValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有类似的东西会弹出给用户以确认更改.如果他单击否",我会将视图模型中的 selectedValue 设置为之前的选择.但它没有在视图中正确显示.请帮忙.
I have something like it will pop to the user for getting confirmation of changes. If he clicks no I am setting the selectedValue in view model to the previous selection. But its not getting displayed correctly in view. Please help.
推荐答案
非常简单的 .NET 4.5.1+ 解决方案:
Very simple solution for .NET 4.5.1+:
<ComboBox SelectedItem="{Binding SelectedItem, Delay=10}" ItemsSource="{Binding Items}" />
它在所有情况下都适用于我.只需在没有赋值的情况下触发 NotifyPropertyChanged 即可回滚.
It's works for me in all cases. Just fire NotifyPropertyChanged without value assignment to rollback.
这篇关于如何使用 WPF MVVM 回滚组合框的选定 SelectedValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文