This is a migrated thread and some comments may be shown as answers.

Undoing Selection Change in MVVM

2 Answers 91 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Masoud
Top achievements
Rank 1
Masoud asked on 25 Nov 2011, 11:42 AM
Hi,

I have a RadCombo in a view that in bound to a ViewModel.  SelectedValue of RadCombo is bound to a property Selected with a backing field. Under certain circumstances I need to "reject" user changes to the selection.  In order to achieve this I did the following

private TL _selected;
 
public TL Selected
{
    get { return _selected; }
    set
    {
        if (<some condition -> don't change selection>)
        {
            RaisePropertyChanged("Selected");
            return;
        }
        _selected = value;
        RaisePropertyChanged("Selected");
    }
}

However the RadCombo still shows the "rejected" value instead.

I am running Version 2011.3.1116.1040.

Thank you for your help!





2 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 28 Nov 2011, 10:04 AM
Hi Klaus,

As far as I know, while a dependency property is changing, it does not listen to INotifyPropertyChanged notifications. The standard WPF ComboBox control behaves in the same way. To workaround this you should call OnPropertyChanged through a dispatcher. You can find attached a sample application that demonstrates how.

Regards,
Valeri Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Masoud
Top achievements
Rank 1
answered on 28 Nov 2011, 05:20 PM
Hi Valeri,

thank you for your reply!

I have implementied your solution and it works fine!

Regards
Tags
ComboBox
Asked by
Masoud
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Masoud
Top achievements
Rank 1
Share this question
or