Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom NavigationPage is not working properly Prism 7 #1166

Closed
KalpeshChheda opened this issue Sep 22, 2017 · 10 comments
Closed

Custom NavigationPage is not working properly Prism 7 #1166

KalpeshChheda opened this issue Sep 22, 2017 · 10 comments

Comments

@KalpeshChheda
Copy link

KalpeshChheda commented Sep 22, 2017

Custom NavigationPage is not working properly

I have navigation like this
await NavigationService.NavigateAsync("app:///TestNavigationPage/MainPage", navPar);
MainPageViewModel's constructor is getting called 2 times
If am changing to
await NavigationService.NavigateAsync("app:///NavigationPage/MainPage", navPar);
MainPageViewModel's constructor is getting called 1 time only which is should be

Package info

  • Platform: Windows/UWP
  • Prism version: Prism Form 7 Pre1
  • Xamarin Forms version (if applicable): 2.4.0 Pre 3

Repro steps

https://www.dropbox.com/s/xlt5o67by7m0vym/PrismUnityApp1.zip?dl=0

@KalpeshChheda KalpeshChheda changed the title Custom NavigationPage is not working properly Custom NavigationPage is not working properly Prism 7 Sep 22, 2017
@brianlagunas brianlagunas added this to the Prism 7.0 milestone Sep 22, 2017
@brianlagunas
Copy link
Member

Good find. This is related to the new ReverseNavigation method added to the NavigationService to address two other bugs. The work around is to add the following ctor to your custom NavigationPage:

        public TestNavigationPage(Page page) : base(page)
        {
            InitializeComponent();
        }

@brianlagunas
Copy link
Member

This has been fixed. You can try it out by using the latest CI build on MyGet

https://www.myget.org/gallery/prism

You should delete that workaround code now :)

@joncortez
Copy link

@brianlagunas - It seems that I still need to have the ctor above if I have a custom NavigationPage on a TabbedPage. Otherwise, I am getting the following exception System.MissingMethodException: Constructor on type 'WellRx.Forms.Views.MyNavigationPage' not found. Is this a regression of the previous bug?

MainTabbed.xaml

<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:views="clr-namespace:MyApp.Forms.Views;assembly=MyApp.Forms"
    x:Class="MyApp.Forms.Views.MainTabbedPage">
	<TabbedPage.Children>
        <views:MyNavigationPage Title="Tab1">
            <x:Arguments>
                <views:Tab1Page />
            </x:Arguments>
        </views:MyNavigationPage>
        <views:MyNavigationPage Title="Tab2">
            <x:Arguments>
                <views:Tab2Page />
            </x:Arguments>
        </views:MyNavigationPage>
	</views:TabbedPage.Children>    
</TabbedPage>

MyNavigationPage.cs

public class MyNavigationPage : NavigationPage
{
   public MyNavigationPage()
   {
      BarTextColor = (Color)Application.Current.Resources["primary-color"];
      BarBackgroundColor = Color.White;
   }
}

Package info

Platform: Visual Studio for Mac
Prism version: Prism Form 7.0.0.396
Xamarin Forms version (if applicable): 2.5.0.280555

@isabirahmed
Copy link

Can confirm the issue still exists and needs the workaround.

@brianlagunas
Copy link
Member

This original issue does not exist anymore. If you are talking about the requirement for having a ctor that accepts a page when using it in a TabbedPage, then that is correct. That is required by the XAML parser to define a NavigationPage in XAML.

@bakhti346
Copy link

I am having the same issue but i am not using a custom navigation page i am using the default navigation page provided by Prism.

@brianlagunas
Copy link
Member

brianlagunas commented Oct 16, 2018

@bakhti346 Prism doesn't provide a default NavigationPage

@JoeDurand3
Copy link

I think he means the default navigation page provided by Forms:

containerRegistry.RegisterForNavigation<CustomNavigationPage>("NavigationPage");
...
navigationService.NavigateAsync("NavigationPage/LoginPage");

I've also tried:

containerRegistry.RegisterForNavigation<CustomNavigationPage>();
...
navigationService.NavigateAsync("CustomNavigationPage/LoginPage");

@brianlagunas
Copy link
Member

@JoeDurand3 I cannot duplicate. Custom navigation pages are working fine for me.

@lock
Copy link

lock bot commented Jan 28, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants