GithubHelp home page GithubHelp logo

Comments (4)

carlosxjose avatar carlosxjose commented on July 30, 2024

You have to do this at MauiProgram.cs

.UsePrism(prism =>
{
    prism.RegisterTypes(cr =>
    {
        //cr.RegisterForNavigation<NavigationPage>();//This is not necesarry
        cr.RegisterForNavigation<MainPage>();
    });
    prism.CreateWindow(async (container, navigation) =>
    {
        var result = await navigation.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainPage)}");
    });
})

At App.xaml.cs

    public App()
    {
        InitializeComponent();

        //MainPage = new AppShell();//This is not necesarry
    }

And voilá

image

from prism.

RobFrancisAu avatar RobFrancisAu commented on July 30, 2024

Thanks you @carlosxjose, turns out (per your comment) the issue in my main project was the registration of the NavigationPage

.UsePrism(prism =>
{
    prism.RegisterTypes(cr =>
    {
        cr.RegisterForNavigation<NavigationPage>(); // THIS IS THE PROBLEM
    });
    prism.CreateWindow(async (container, navigation) =>
    {
        var result = await navigation.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainPage)}");
    });
})

This has fixed the crashing but has also caused a styling issues. I am currently styling like this, which worked in Xamarin

<Style TargetType="NavigationPage">
        <Setter Property="BarBackgroundColor" Value="{DynamicResource NavigationBarColour}" />
        <Setter Property="BarTextColor" Value="{DynamicResource NavigationBarTextColour}" />
</Style>

The DynamicResource allowed me to switch between multiple themes at runtime. I understand this is a completely seperate issue, but this did work prior to 9.0.401-pre.

from prism.

dansiegel avatar dansiegel commented on July 30, 2024

@RobFrancisAu Prism does not directly use the NavigationPage but rather uses a customized PrismNavigationPage. You can simply update your style to match either of the following

<Style TargetType="NavigationPage" ApplyToDerivedTypes="True">
</Style>

<Style TargetType="prism:PrismNavigationPage">
</Style>

from prism.

RobFrancisAu avatar RobFrancisAu commented on July 30, 2024

Fantastic, thanks @dansiegel ! That did the trick.

from prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.