Saturday, December 27, 2014

Does ObservableCollection.RemoveAt() do two selections?

I am using MVVM pattern application, and I have a property that binds the SelectedIndex property of a comboBox.


This is my view model.



private int _mySelectedIndex;
public int MySelectedIndex
{
get { return _mysSelectedIndex; }
set
{
_mySelectedIndex = value;
base.RaisePropertyChangedEvent("MySelectedIndex");
}

When I do:



myObservableCollection.RemoveAt(1);

The selectedIndex property is set twice, the fisrt time set -1 and the second one 1, the index that has the element that I had selected when I try to delete the ítem.


I would like to know why the selected index is changed twice, I think that it would be just once.


thank so much.


No comments:

Post a Comment