2

I already have a solution which consist of Xamarin.iOS and UWP. We have multiple views (Pages) in both platforms. We are using MvvmCross, so we have a common code (PCL) which consists of Viewmodels, business logic etc. Also, we have separate views (Pages) for both Xamarin.iOS and UWP.

Now I want to add Xamarin.Forms support for native pages of both projects so that we have same views for both Xamarin.iOS and UWP. We need the support of navigation (from Native to Xamarin.Forms & vice versa). I am navigating through MvvmCross navigation service.

For instance, I have FirstFormView in Xamarin.Forms project. I have SecondFormView in Native project (can be Xamarin.iOS or UWP). I have ThirdFormView in Xamarin.Froms project.

I have navigated to FirstFormView (which is staring page of my application) Now I want to go to SecondFormView (which is in native project). And from SecondFormView I need to go to ThirdFormView which is again in Xamarin.Forms

Is it possible to do it MvvmCross? If yes, then what steps should we follow to achieve our desired goal.

Thanks in advance.

Regards,

2 Answers 2

2

This is possible through the Forms presenters. Take a look at the playground: https://github.com/MvvmCross/MvvmCross/tree/develop/TestProjects/Playground/Playground.Forms.Droid

Here the views are all Forms, but 1 or 2 are in Native. By using the same solution you should be able to do this.

Sign up to request clarification or add additional context in comments.

4 Comments

is there any example available for UWP as well?
Yes it is in the same repo
Yes, but native views are not implemented for uwp in this solution
1

You already have MvvmCross in your PCL project, just need to add Xamarin Form pages (XAML) for every page in platform specific project (iOS, UWP). And custom renderers for every platform.

For example:

//in xamarin forms pcl project
namespace XFormProject
{
    public class MyXFormPage : ContentPage project
    {

    }
}

// in ios project
namespace XFormProjecy.iOS
{

    [assembly:ExportRenderer(typeof(XFormProject.MyXFormPage), typeof(XFormProject.iOS.MyXFormPageIOS))]
    public class MyXFormPageIOS : PageRenderer // in iOS
    {
        // your ios native page code goes here.
    }
}

Read more about Custom Rederers

Hope this helps :)

6 Comments

How can I navigate from Native page to Xamarin.Form page and vice versa?
a form page should represent your native page like in the example above. Then you can navigate in forms project just like from one form page to another
I am navigating through MvvmCross's NavigationService.
For instance, I have FirstFormView in Xamarin.Forms project. I have SecondFormView in Native project (can be Xamarin.iOS or UWP). I have ThirdFormView in Xamarin.Froms project. I have navigated to FirstFormView (which is staring page of my application) Now I want to go to SecondFormView (which is in native project). And from SecondFormView I need to go to ThirdFormView which is again in Xamarin.Forms
Create XamarinForm page for SecondView and bind it with custom native views in ios and uwp. then you can do the navigation in forms project without communicating to native project.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.