Xamarin Forms:主从页面中的重复工具栏
Xamarin Forms: duplicated Toolbar in Master Detail Page
我目前正在使用 Xamarin Forms 和 Andoird 开发一个项目(iOS 稍后将添加支持)。
该应用程序有一个 MasterDetailPage
作为 HomePage
和一个 ToolBar
,工作正常。
在我的一个 DetailPages
中有一个 ToolbarItem
链接到另一个页面:
Navigation.PushAsync(new NavigationPage(new ShoppingCartPage()));
当我在 ShoppingCartPage
时,我得到了一个重复的工具栏,我不知道为什么(请参阅 ScreenshotPhone)
任何人都可以告诉我如何只显示一个工具栏的正确方向。
奇怪的是,ShoppingCartPage
上的 ToolbarItem
显示了两次。
XAML 来自 ShoppingCartPage:
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="toolbarItemFinishOrder" Activated="FinishOrder" Icon="wallet_64.png">
</ToolbarItem>
</ContentPage.ToolbarItems>
<StackLayout>
XAML 来自链接到 ShoppingCartPage 的页面:
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="toolbarItemShoppingCart" Activated="ShoppingCart_Clicked" Icon="shoppingCart2_64.png"></ToolbarItem>
</ContentPage.ToolbarItems>
</ContentPage>
链接到 ShoppingCartPage 的页面代码:
public partial class ArticleSearchPage : ContentPage
{
public ArticleSearchPage()
{
InitializeComponent();
this.Content = new ArticleSearchView();
//TODO: Localization
this.Title = "Artikel";
}
protected void ShoppingCart_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new NavigationPage(new ShoppingCartPage()));
}
我希望我说清楚了,希望你能帮助我。
提前致谢!
用这个看看:
Navigation.PushAsync(new ShoppingCartPage());
我目前正在使用 Xamarin Forms 和 Andoird 开发一个项目(iOS 稍后将添加支持)。
该应用程序有一个 MasterDetailPage
作为 HomePage
和一个 ToolBar
,工作正常。
在我的一个 DetailPages
中有一个 ToolbarItem
链接到另一个页面:
Navigation.PushAsync(new NavigationPage(new ShoppingCartPage()));
当我在 ShoppingCartPage
时,我得到了一个重复的工具栏,我不知道为什么(请参阅 ScreenshotPhone)
任何人都可以告诉我如何只显示一个工具栏的正确方向。
奇怪的是,ShoppingCartPage
上的 ToolbarItem
显示了两次。
XAML 来自 ShoppingCartPage:
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="toolbarItemFinishOrder" Activated="FinishOrder" Icon="wallet_64.png">
</ToolbarItem>
</ContentPage.ToolbarItems>
<StackLayout>
XAML 来自链接到 ShoppingCartPage 的页面:
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="toolbarItemShoppingCart" Activated="ShoppingCart_Clicked" Icon="shoppingCart2_64.png"></ToolbarItem>
</ContentPage.ToolbarItems>
</ContentPage>
链接到 ShoppingCartPage 的页面代码:
public partial class ArticleSearchPage : ContentPage
{
public ArticleSearchPage()
{
InitializeComponent();
this.Content = new ArticleSearchView();
//TODO: Localization
this.Title = "Artikel";
}
protected void ShoppingCart_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new NavigationPage(new ShoppingCartPage()));
}
我希望我说清楚了,希望你能帮助我。 提前致谢!
用这个看看:
Navigation.PushAsync(new ShoppingCartPage());