我试图将这些工具栏添加到我的内容页面,如果它是navigaitionstack的第一页,它就可以工作。但如果我把它作为第二个使用,我就无法获得任何菜单。如何让Issueite出现在IssuePage上而不将其作为我的起始页?
public partial class IssuesPage : ContentPage
{
var home = new ToolbarItem
{
Text = "Add New",
Icon = "Add.png",
Order = ToolbarItemOrder.Primary,
Priority = 0,
};
home.Clicked += this.OnClickNewIssue;
this.ToolbarItems.Add(home);
var map = new ToolbarItem
{
Text = "Map",
Icon = "map.png",
Order = ToolbarItemOrder.Primary,
Priority = 0,
};
map.Clicked += this.OnClickShowMap;
this.ToolbarItems.Add(map);
var loginLocation = new ToolbarItem
{
Text = "Login and Location",
Icon = "menu.png",
Order = ToolbarItemOrder.Secondary,
Priority = 0,
};
loginLocation.Clicked += this.OnClickLoginLocation;
this.ToolbarItems.Add(loginLocation);
var filter = new ToolbarItem
{
Text = "Filter and Sorting",
Icon = "filter.png",
Order = ToolbarItemOrder.Secondary,
Priority = 1,
};
filter.Clicked += this.OnClickSetFilter;
this.ToolbarItems.Add(filter);
}
以后是页面顺序。
public App()
{
Client = new AppIssueClient();
// The root page of your application
MainPage = GetMainPage();
}
public static Page GetMainPage()
{
return new NavigationPage(new IssueCarouselPage(new UIIssueVM(true)));
}
这就是我从IssueCarosuelPage
转到IssuePage的方法void OnGoToEventList(object sender, EventArgs args)
{
Navigation.PushModalAsync(new IssuesPage(-1));
}
答案 0 :(得分:0)
原因是使用PushModalAsync
你在堆栈上推送一个全新的页面,它不仅取代了IssueCarouselPage
,还取代了包裹它的NavigationPage
。因此,您将丢失工具栏功能。要解决此问题,请执行以下操作:
void OnGoToEventList(object sender, EventArgs args)
{
Navigation.PushModalAsync(new NavigationPage(new IssuesPage(-1)));
}
现在,您将在堆栈上推送一个包含新IssuesPage
的新导航页面,导航页面将提供工具栏。或者,您只能使用PushAsync
进行分层导航:
void OnGoToEventList(object sender, EventArgs args)
{
Navigation.PushAsync(new IssuesPage(-1));
}
您应该使用哪一个取决于您的具体用例。在this blog article中对两种导航形式进行了非常好的比较。