|I'm a long time WPF developer. I am working on a WPF business app for a client and I'm going to be developing an Android tablet app to go with it. This is my first Xamarin Forms project, so bear with me...
I followed the tutorials here Xamarin documentation - Xamarin | Microsoft Docs under "Get started with Xamarin.Forms", "Build Your First App". I went through all four projects. Everything works fine.
So I then decided to convert the project to MVVM. One thing that I found through Googling is that if you want a View Model to open a new page, your View Model has to know about the INavigation property on the Page See this. What concerns me is that INavigation has to be passed from the UI into the CTOR of the VM. IMHO, This creates a few problems:
1) The VM must be set in the CTOR of the view. That prevents you from doing this.
2) A UI property now has to be passed to the VM.
3) Doing it this way means that you cannot share VMs between WPF and Xamrin Forms projects as WPF doesn't have INavigation.
One this last point... I got the impression from reading up on Xamarin Forms that it's all about sharing code. It seems to me that I could have VMs in a shared project, and use the them in both WPF and Xamarin Forms apps. For example, a LoginViewModel is a good candidate.
Again, I'm very new to Xamarin Forms. I would like to share VMs if I can. I'm open to hearing how this should work.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 28-Jan-20 11:18am.