Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ListView SelectedValue lost after Async updated ItemsSource Item

$
0
0

The WPF app is developed strictly in MVVM pattern

Let's say I have a List included 3 items in ViewModel

var Items = new List<Item> { Item1, Item2, Item3}

<ListViewMargin="5,5,5,20" SelectionMode="Single"	SelectedValue="{Binding SelectedItemObj}"IsSynchronizedWithCurrentItem="True"ItemsSource="{Binding Items, Mode=OneWay}">

And the user click on the grid on Item2
So, the SelectedValue = Item2

A service async updated the Items collection at seperate thread by

Items[1] = NewItem;

Because of that, the SelectedValue in the ListView is lost

And one of the side note is that the async update is very frequent

Please hope if there's anyone who can suggest a solution for me

Million Thanks


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>