英文:
How to create a NON Shell App in .NET MAUI?
问题
我们已经做出了一个决定,使用Shell导航有点受限制和繁琐,我们打算使用我们自己的Flyout页面,但Shell应用程序中不允许使用它们。但是,当我们尝试创建一个新的应用程序时,没有选项来创建一个带有Shell或不带Shell的应用程序?所以我们创建了默认的应用程序,然后简单地删除了AppShell对象,这似乎可以工作,但是我们需要做的就只有这些吗,才能使用我们自己的Flyout页面吗?
英文:
We have made a decision that using Shell navigation is just a little restrictive and cumbersome and we are going to utilize our own Flyout pages which are not allowed in shell apps BUT when we move to create a new app, there is no option to create a shell/non shell app??? So we created default app then simply deleted the appshell object which seems to work BUT is this all that is required in order for us to utilize our own flyout pages?
答案1
得分: 1
以下是翻译好的部分:
"Its as simple as changing MainPage = new AppShell();
in App.xaml.cs, to whatever you want:"
这就是更改 App.xaml.cs 中的 MainPage = new AppShell();
,到你想要的任何内容:
"MainPage = new NavigationPage(new MyFirstPage());
"
如果你想要使用 NavigationPage 的导航功能。
"Otherwise simply MainPage = new MyFirstPage();
, and then roll your own page changes via Application.Current.MainPage = a SomeOtherPage();
."
否则,只需 MainPage = new MyFirstPage();
,然后通过 Application.Current.MainPage = a SomeOtherPage();
自行更改页面。
"Substitute the appropriate class name for MyFirstPage
. E.g. in the Maui template, it is class MainPage
, so use MainPage
if you want to immediately test a new Maui project."
用适当的类名替代 MyFirstPage
。例如,在 Maui 模板中,它是 class MainPage
,所以如果你想立即测试一个新的 Maui 项目,可以使用 MainPage
。
"Note that both these solutions involve explicitly calling new YourPageNameHere()
rather than relying on Dependency Injection. This may affect code you need to write elsewhere (compared to Maui examples you'll find, which tend to rely on DI)."
请注意,这两种解决方案都涉及显式调用 new YourPageNameHere()
而不是依赖于依赖注入。这可能会影响你需要在其他地方编写的代码(与你可能会找到的依赖于 DI 的 Maui 示例相比)。
英文:
Its as simple as changing MainPage = new AppShell();
in App.xaml.cs, to whatever you want:
MainPage = new NavigationPage(new MyFirstPage());
if you want to use NavigationPage's navigation features.- Otherwise simply
MainPage = new MyFirstPage();
, and then roll your own page changes viaApplication.Current.MainPage = new SomeOtherPage();
.
Substitute the appropriate class name for MyFirstPage
. E.g. in the Maui template, it is class MainPage
, so use MainPage
if you want to immediately test a new Maui project.
Note that both these solutions involve explicitly calling new YourPageNameHere()
rather than relying on Dependency Injection. This may affect code you need to write elsewhere (compared to Maui examples you'll find, which tend to rely on DI).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论