Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Xamarin Forms & WPF Question

Xamarin Forms & WPF Question

Scheduled Pinned Locked Moved Mobile
wpfmobilecsharpandroidcom
2 Posts 2 Posters 15 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    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](https://docs.microsoft.com/en-us/xamarin/) 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](https://forums.xamarin.com/discussion/147142/navigation-in-viewmodel). 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](https://stackoverflow.com/questions/4590446/how-do-i-set-a-viewmodel-on-a-window-in-xaml-using-datacontext-property). 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. Thanks

    If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

    V 1 Reply Last reply
    0
    • K Kevin Marois

      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](https://docs.microsoft.com/en-us/xamarin/) 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](https://forums.xamarin.com/discussion/147142/navigation-in-viewmodel). 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](https://stackoverflow.com/questions/4590446/how-do-i-set-a-viewmodel-on-a-window-in-xaml-using-datacontext-property). 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. Thanks

      If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      hi Kevin Why do you want to mix Xamarin form and WPF if i may ask ? You can create a Xamarin Standard Project and create the content pages there and other types of pages or views you want to add , after that do your UI there and if there is a limitation on the Xamarin Forms you can use Custom Renders and this UI changes you have made in the standard form will be outputted to different platforms which is ios and Android. i know you have knowledge of WPF , you can use it on Xamarin Form. but leave WPF out of Mobile dev for now.

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups