Atm I got a class(somerandomclasss) with a static ObservableCollection:
public static ObservableCollection<PersonViewModel> thepeoplelist = new ObservableCollection<PersonViewModem>();
However, I am converting my project to MVVM and of course this is not a good way to fill all my itemscontrols(listviews mainly) I got multiple windows that use this source in this way.
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
lsvallthepeople.ItemSource = somerandomclasss.thepeoplelist;
}
The listview displays then all the people with the info.
However this isn t the MVVM way I bet, and I haven’t found a good way to work without a public static ObservableCollection, however there is a window where you got a listview where you can edit the persons, they get updated in the SQL database and in the PersonViewModel (that got the INotifyPropertyChanged).
If you need any more information feel free to ask ofc :).
You can either use a
Staticbinding to bind yourItemsSourceinstead of setting it in your code-behind manuallyor expose a property which returns the collection from your ViewModel and bind to that property