Cross-platform application development should reach the largest potential customer base it can. With Xamarin.Forms, you can create a solution with projects that target Android, iOS, Windows 10, Windows Mobile, Windows 8.1, and Windows Phone 8.1 out-of-the-box. Unfortunately, Windows Desktop is not included with this template. With so many people still using and relying on traditional Windows Desktop applications, many times it is important to provide a solution for that target environment.

Fortunately, with only a few modifications, we can refactor our default Xamarin.Forms solution to include a WPF project. Furthermore, we will establish a project structure that ensures all the projects can still utilized common code (things like View Models, Services, Models) from a PCL project within the solution.

We will cover the following activities:

Creating a new solution from the default Xamarin.Forms project template

Adding a Core PCL to our solution, to contain our common code

Add some common code to our Core PCL

Using a simple IoC container to replace Xamarin.Forms DependencyService class

What you'll need to do is create a new PCL with the same profile as your existing Forms PCL. Add references to the new PCL from your existing projects. You can then migrate your Model and View Model layers to this new PCL. You won't be able to share your XAML views because WPF XAML != Forms XAML.

You can then create your WPF project and have it reference the new PCL as well. It can reuse the Model and View Model layers.

If you use DependencyService, you will need to replace it with an IoC container, I've used TinyIoC in the past, and it has worked well for me. You'll also need to implement navigation for WPF. The best approach would be to abstract your navigation to an Interface, then wire the implementation in Forms/WPF with IoC.

If you are using an MVVM framework, there's good news and bad news. Frameworks like MvvmCross and ReactiveUI support both WPF and Forms, so the majority of the work will be implementing the framework components in your WPF project. If you are using a dedicated Forms MVVM framework, it may not have any support for WPF.

If you are using a forms-specific MVVM framework, you will have the most work to do because you'll need to decouple from that framework in order to support WPF.

Hopefully this will give you an idea of the level-of-effort for your specific solution.

I realise this is an old article but it's one of the few I can find on adding WPF to a XF solution. I'm looking at using Prism for XF (6.3.0) and given the historical association between Prism and WPF was rather surprised to find that the Prism target wizard does not mention WPF. Will this tutorial work for Prism as well or is it going to require something totally different? I am looking at creating a XF solution that targets iOS, Android UWP and classic desktop and we already have Prism experience in the company. I was hoping that Prism for XF would naturally include a WPF target!

The navigation support for XF for example is radically different to WPF but Prism supports UWP & WPF but you can't target all these platforms in one solution, I don't know of an application framework (that's not very basic) that does.

That's no comment on the work above but what I mean is you can't have a fully featured MVVM framework that targets all these technologies for now, if I'm wrong I'm more than happy to be corrected.

First of all, we want to thank you for your dedication to improve the PRISM framework during all these years.

We are a company that has been using PRISM in multiple WPF projects for many years.

Now, we want to develop a new multiplatform application for mobile, tablet, desktop, etc. Following your TODO app (https://github.com/brianlagunas/TodoApp), we have started by creating a solution for each device. For example, the desktop solution is created with WPF and the mobile solution with Xamarin.Forms. We can reuse most of the code by sharing the view models which are .Net Standard libraries that use PRISM.Core.

However, Microsoft recently announced that Xamarin.Forms will support WPF in addition to Linux and MacOS.

Before this, we understood that Xamarin.Forms was only for mobile applications. However, after this announcement, Xamarin.Forms will also start to be used as a framework for desktop applications.

That is the reason why we are thinking to work with Xamarin.Forms as a main development framework for all our applications, both for mobile and desktop devices. We could have different solutions for each device, but all of them would work with Xamarin.Forms with all the advantages that it represents (only one xaml to learn, only one framework, etc.).

The problem is that PRISM for Xamarin.Forms does not have the concept of region. For us, in tablet or desktop solutions, this feature is essential to be able to create modular applications.

@juapepa I am not sure about adding region support to XF or not. Honestly, I personally would not use XF to create an app for WPF. If your app is simple and needs very basic linear frame-based navigation, and you want it to be the exact same app on all devices, then this might be an option for you. The WPF apps I build are much more complicated than that. Then again, Xamarin might surprise me and make it extremely flexible.

I have a number of other priorities I am working on at the moment, but I suggest submitting a request for regions in XF on the GitHub site. We can gauge community interest and have a more thoughtful conversation there. If regions were added, it would be a completely different API that what exists in WPF now, and most like much more limited due to the nature of XF.