Change the page creation in the PageNavigationService #2247
Unanswered
Grzesik
asked this question in
Xamarin.Forms
Replies: 1 comment 1 reply
-
I'm not going to do a CreateRawPage, but we can make the private method protected that way you can access it in your override. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
in one of my Xamarin.Forms projects I create the Xaml pages dynamically (from a text file). To use Prism for the project I inherited a class from the class PageNavigationService and overrode the function
protected override Page CreatePage(string segmentName)
In the Prism Version 7 the function was quite easy to override:
instead of the container.Resolve(segmentName) as Page; I created the page dynamically, like this new ContentPage().LoadFromXaml(xaml);
In the Prism version 8 the function is more complicated:
To override the function, I needed to implement the function SetNavigationServiceForPage, because it is private. Unfortunately in the function is the Xaml.Navigation.NavigationServiceProperty internal and implemented as a static class. I needed also to copy the Navigation class.
I suggest to change the implementation of the CreatePage function. The easiest way is to change the function SetNavigationServiceForPage to protected. The other possibility is to create a virtual function for a part of the the page creation:
and use it in the CreatPage function.
Thanks
Marian
Beta Was this translation helpful? Give feedback.
All reactions