i'm working in wpf mvvm for first time, and i'm having some problems in ''problems of real life''
I have a ViewModel, with its view, from where I must open a second view (with its ViewModel, which will have a list of objects) and here, I must choose one object, to return it to the first ViewModel, where i will work with it.
I'm using a simple approach to open the second window, I know I broke the mvvm pattern a bit
public object ShowDialog<TView, TViewModel>(TViewModel dataContext) where TView : IWindow, new() where TViewModel : BaseViewModel<TViewModel>
{
//Instancio la vista.
TView view = new TView();
WindowService wnd = new WindowService(view);
dataContext?.SetWindowService(wnd);
view.DataContext = dataContext;
view.ShowDialog();
return dataContext;
}
And in the ViewModel i'm opening the second page like this
WindowService.ShowDialog<ChooseOneCat, ChooseOneCatViewModel>(null);
Then in the ChooseOneCat
ViewModel, I let the user choose the category that I must return later
And here is my issue, how can i give that object to the first viewmodel?
Pd: i dont use any extra framework.
Thanks!