I'm currently developing an app in WPF using the MVVM pattern ( without framework ). I use VS2019, Each view is an UserControl The app is connected to a local database MySQLLite.
When I start my program, I have an user connection. When the user connection is successful, it loads my object "Engine" in my global class "BaseViewModel" ( inherit all ViewModel ).
In WinForm when I create a new Form(View), I just transfer my Engine class in parameters and I save the Engine locally in my Form ( not null ) and then I have access to my value in Engine like User.
What is the best way to do it in WPF using MVVM?
I try to transfer the Engine to my ViewModel when I create but it always overwrites it later with null. Because it opens the view without parameter later and calls my constructor without parameter.