Forum Xamarin.Forms

How do you open a native WP page from a Xamarin Form


New to Xamarin. What I want to do is open a native page for each platform from a Xamarin form. I've found out how to do it for Android - Forms.Context.StartActivity(myIntent), how would I do it for Windows Phone? I thought it would use Forms.ConvertPageToUIElement, as that is all that is exposed for WP build, but I get an exception. I know about the PageRenderer way, which I can do, but I'd like to know if it's possible to open a native page?
If someone does know the answer, could you also include how you do it for iOS, for when I get around to that.

Thanks in advance



  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    Ah... I too needed that. In absence of any guidance, I built a XF Page and calling it from WP class which is called from XF using Dependency Service.

    For iOS, PresentViewController should work as used in this Send a Tweet sample.

  • Thanks Shantimohan, I will look at that. If anyone else knows if that is the way or there is a different preferred method, please let me know.

  • A solution I thought of was to do something similar to what happens for the main page, where you have a PhoneApplicationPage class to represent the current page you want to navigate from to a native WP page, and use the ConvertPageToUIElement function of the current Xamarin.Form to set the content, e.g.

                PhoneApplicationPage currentPage = new CurrentFormsPage();
                currentPage.Content = xamarinFormsPage.ConvertPageToUIElement(currentPage);
                currentPage.NavigationService.Navigate(new Uri(newPageUri));

    Problem is I get an exception - "Can not create more than one Application instance". I saw someone else raised this on another thread, which unfortunately no-one replied - .

    If someone could explain how to get around this, please let me know.

  • Update: I updated Xamarin, and exception is now - "Element is already the child of another element.".

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    In X.F 1.3.x PhoneApplicationPage is not used anymore. It is replaced by FormsApplicationPage. So which XF version are you using?

    Where are you running this code, in the shared/pcl project or in WP project? Probably you should create a Dependency class in WP project and Navigate your WP Page from that.

  • XF ver
    It's a shared XF solution, running WP project. From one of the XF, I want to open a native page which I've done for Android, now trying to do for WP. What I done is have a class in WP project with that code above to open the native page. It's similar method to the main WP page. If it can't be done like that, then I'll look at the Dependency class you suggest.

  • From this sample - , I've come to the conclusion you can't. So I'm using the PageRenderer method.

Sign In or Register to comment.