I am developing a WPF application for displaying data in a plot. I have a UserControl
that acts as a View
. In its codebehind file, I have created an ObservableCollection<MyViewModel>
. These are displayed in the DataGrid
.
public partial class TagGridView : UserControl
{
private TagGridViewModel _tagGridViewModel = new TagGridViewModel();
I have another UserControl
, acting as another View
that has a Button
in it. The button opens a file dialog. I would like to be able to use the result of the file dialog operation from the separate view to add an item to the ObservableCollection<MyViewModel>
, thus updating the grid.
Am I supposed to have a MainViewModel
in every view containing a static instance of all other ViewModels
that are required? How can I access the collection?