WPF ComboBox SelectedItem - change to previous value

Posted by Taylor on Stack Overflow See other posts from Stack Overflow or by Taylor
Published on 2010-04-06T13:35:42Z Indexed on 2010/04/06 14:03 UTC
Read the original article Hit count: 375

Filed under:
|
|

Hello, I have a ComboBox that has the SelectedItem bound to the ViewModel.

<ComboBox SelectedItem="{Binding SelItem, Mode=TwoWay}" ItemsSource="{Binding MyItems}">

When the user selects a new Item in the View ComboBox, I want to display a prompt and verify that they want to make the change.

In the SetItem Property setter in the View Model, I display a Dialog to confirm the selection. When they say yes, it works fine.

My problem is, when the user clicks on "No" I am not sure who to get the ComboBox to revert back to the previous value. The Property in the ViewModel has the correct older value, however in the View the ComboBox displays the newly Selected Value.

I want the user to select an item, confirm they want to go ahead with it, and if they decide not to, I want the ComboBox to revert back to the previous item.

How can I accomplish this? Thanks!

© Stack Overflow or respective owner

Related posts about wpf

Related posts about combobox