I am using MVVM light to bind a ListView to an ItemSource on my ViewModel. When a change is made to the property on the ViewModel the SelectedItem does not update in the View.
XAML:
<ListView Grid.Row="1"
SelectionMode="Single"
ItemsSource="{Binding filteredAppListItemSource}"
SelectedItem="{Binding selectedApp, Mode=TwoWay}">
ViewModel:
public Model.V_PWT_APP_ALL selectedApp
{
get { return this._selectedApp; }
set {
this._selectedApp = value;
RaisePropertyChanged(() => selectedApp);
}
}
Selecting an Item from the View updates the ViewModel and all controls that derive their data from SelectedItem are updated. The TwoWay binding does not seem to be working.
If you would like to stay with the INotified property changed interface you should set up the code as in the following documentation: https://msdn.microsoft.com/en-us/library/ms184414(v=vs.110).aspx .
As it does not seem like you are changing properties, but rather items and notifying the ItemsSource, a better route would be to implement an IObserver/IObservable interface. This is a little more simple and it keeps updating tidy and manageable inside of the models own class. Here is a possible code example:
For the viewModel:
This might seem tedious at first, but it has helped me minimize and manage updates and bugs in ItemsSource quite nicely. Finally, I have found controlling the scrollView rather tedious when working with the ListView ItemsSource, and have had better luck with simply using ListView.Items.Insert(...) method as when the ItemsSource is updated and a scrollview has been selected it has often thrown an OutOfRange exception. This can be difficult debugging in MVVM. However, this is another topic. I hope this helps.