Xaml Xamarin表单工具栏项在选项卡式页面中出现两次
我在选项卡式页面中添加了一个名为refresh的工具栏项,下面是选项卡式页面的代码Xaml Xamarin表单工具栏项在选项卡式页面中出现两次,xaml,xamarin,xamarin.forms,xamarin.android,xamarin.ios,Xaml,Xamarin,Xamarin.forms,Xamarin.android,Xamarin.ios,我在选项卡式页面中添加了一个名为refresh的工具栏项,下面是选项卡式页面的代码 <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/fo
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Xapp;assembly=Xapp"
mc:Ignorable="d"
x:Class="Xapp.HomePage">
<TabbedPage.ToolbarItems>
<ToolbarItem x:Name="Refresh" Text="Refresh" />
</TabbedPage.ToolbarItems>
<TabbedPage.Children>
<NavigationPage Title="report">
<x:Arguments>
<local:ReportPage>
<StackLayout>
<Label Text="In:" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding CountIn}" FontSize="Medium" FontAttributes="Bold" />
<Label Text="Out:" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding CountOut}" FontSize="Medium" FontAttributes="Bold" />
<Label Text="Date:" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding createdon}" FontSize="Medium" FontAttributes="Bold" />
</StackLayout>
</local:ReportPage>
</x:Arguments>
</NavigationPage>
<NavigationPage Title="history">
<x:Arguments>
<local:HistoryPage />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
问题是刷新在工具栏中出现两次,如下图所示:
如果应用程序的主页是一个选项卡页。您不需要将其设置为NavigationPage。应用程序内 修改App.Xaml.CS中的代码
public App()
{
InitializeComponent();
MainPage = new HomePage();
}
更新
从内容页面导航到选项卡页面不是一个好的设计
因此,请将代码修改为
App.Current.MainPage = new HomePage();
而不是
page.Navigation.PushAsync(新主页())代码>主页是一个内容页,可导航到包含上述代码的选项卡式页面。很抱歉,您能告诉我学习xamarin的教程或书籍的名称吗