我有一個組合框,將SelectedItem綁定到ViewModel。WPF組合框SelectedItem - 更改爲以前的值
<ComboBox SelectedItem="{Binding SelItem, Mode=TwoWay}" ItemsSource="{Binding MyItems}">
當用戶選擇查看組合框一個新的項目,我想顯示一個提示並確認他們希望做出改變。
在View Model的SetItem Property setter中,我顯示一個對話框來確認選擇。當他們說是的,它工作正常。
我的問題是,當用戶點擊「否」時,我不確定誰能讓ComboBox 恢復到以前的值。 ViewModel中的屬性具有正確的 舊值,但在視圖中,ComboBox顯示新選定的值。
我想要用戶選擇一個項目,確認他們想要繼續它,如果他們 決定不,我希望組合框恢復到以前的項目。
我該如何做到這一點? 謝謝!
這真是棒極了 - 謝謝!我不確定如何重新發送消息以便View更新。 – 2010-04-06 18:28:58
由於[WPF 4.0中的更改](https://karlshifflett.wordpress.com/2009/05/27/wpf-4-0-data-binding-change-great-feature/)請按照更多[完整解決方案@ NathanAW](http://stackoverflow.com/a/2709931/197371) – 2015-05-04 20:19:59