问题描述
我正在尝试使用Xamarin Forms中的Prism创建一个应用程序.
Xamarin Forms版本:2.3.3.175
原始版本:6.2.0
汉堡包菜单可在Android中使用,但是当我运行UWP时,它不会显示图标,而且当我浏览菜单时,菜单完全消失,并且我也不会回到其他页面.换句话说,我需要关闭并重新启动应用程序.
这是我到目前为止尝试过的.
-
创建棱镜项目后,我添加了一个MasterDetailPage:
<MasterDetailPage.Master> <ContentPage Title="Default"> <StackLayout> <Button Text="Billing" Command="{Binding Path=NavigationCommand}" CommandParameter="MyNavigationPage/BillingPage"/> <Button Text="Your Order" Command="{Binding Path=NavigationCommand}" CommandParameter="MyNavigationPage/PlaceOrderPage"/> <Button Text="Settings" Command="{Binding Path=NavigationCommand}" CommandParameter="MyNavigationPage/SettingsPage"/> <Button Text="Settings"/> </StackLayout> </ContentPage> </MasterDetailPage.Master>
MasterDetailPage ViewModel
public class MDPageViewModel : BindableBase
{
private INavigationService _navigationService;
public DelegateCommand<string> NavigationCommand => new DelegateCommand<string>(Navigation);
public MDPageViewModel(INavigationService navigationService)
{
_navigationService = navigationService;
}
private void Navigation(string page)
{
_navigationService.NavigateAsync(page);
}
}
-
此后,我创建了一个导航页面以及相应的页面和视图模型.这是App.Xaml.cs文件:
公共局部类App:PrismApplication { 公共应用(IPlatformInitializer初始值设定项= null):base(initializer){}
protected override void OnInitialized() { InitializeComponent(); NavigationService.NavigateAsync("MDPage/MyNavigationPage/ItemsPage"); } protected override void RegisterTypes() { Container.RegisterTypeForNavigation<MDPage>(); Container.RegisterTypeForNavigation<BillingPage>(); Container.RegisterTypeForNavigation<PlaceOrderPage>(); Container.RegisterTypeForNavigation<SettingsPage>(); Container.RegisterTypeForNavigation<MyNavigationPage>(); } }
-
所以当我在UWP中运行该应用程序时,它会像这样加载
但是,当我单击菜单中的链接时,菜单将消失,看起来像这样.
我在做什么错了,我该如何解决?
我在github中创建了一个项目,因此您可以轻松查看错误.
https://github.com/codemasterblackperl/Hamburger_Menu_Prism_Forms_Repo
这是最新版本的Xamarin中的错误.使用2.3.1.114时可以使用.我已经在此处发布了该错误. >
I am trying to create an app using Prism in Xamarin Forms.
Xamarin Forms Version: 2.3.3.175
Prism Version: 6.2.0
The hamburger menu works in Android but when I run it UWP it won't display the icon and also when I navigate through menu, the menu totally disappears and I wont have the method go back to other pages too. In other words, I need to close and restart the app.
Here is what I tried so far.
After creating the prism project I added a MasterDetailPage:
<MasterDetailPage.Master> <ContentPage Title="Default"> <StackLayout> <Button Text="Billing" Command="{Binding Path=NavigationCommand}" CommandParameter="MyNavigationPage/BillingPage"/> <Button Text="Your Order" Command="{Binding Path=NavigationCommand}" CommandParameter="MyNavigationPage/PlaceOrderPage"/> <Button Text="Settings" Command="{Binding Path=NavigationCommand}" CommandParameter="MyNavigationPage/SettingsPage"/> <Button Text="Settings"/> </StackLayout> </ContentPage> </MasterDetailPage.Master>
MasterDetailPage ViewModel
public class MDPageViewModel : BindableBase
{
private INavigationService _navigationService;
public DelegateCommand<string> NavigationCommand => new DelegateCommand<string>(Navigation);
public MDPageViewModel(INavigationService navigationService)
{
_navigationService = navigationService;
}
private void Navigation(string page)
{
_navigationService.NavigateAsync(page);
}
}
After that I created a navigation page and also respective pages and view models. Here is App.Xaml.cs file:
public partial class App : PrismApplication { public App(IPlatformInitializer initializer = null) : base(initializer) { }
protected override void OnInitialized() { InitializeComponent(); NavigationService.NavigateAsync("MDPage/MyNavigationPage/ItemsPage"); } protected override void RegisterTypes() { Container.RegisterTypeForNavigation<MDPage>(); Container.RegisterTypeForNavigation<BillingPage>(); Container.RegisterTypeForNavigation<PlaceOrderPage>(); Container.RegisterTypeForNavigation<SettingsPage>(); Container.RegisterTypeForNavigation<MyNavigationPage>(); } }
So when I run the app in UWP it loads like this
But when I click on the links in menu , menu will disappear and it looks like this.
What I am doing wrong and How can I solve it?
I created a project in github so you can easily view the error.
https://github.com/codemasterblackperl/Hamburger_Menu_Prism_Forms_Repo
This is a bug in the latest version of Xamarin. It works when using 2.3.1.114. I've posted the bug here since i just ran into this.
这篇关于汉堡菜单棱镜xamarin形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!