Xaml 表单:在ContentPage中不可见工具栏项
我正在为我的项目使用Xamarin.Forms&我需要在页面顶部有工具栏。 我试图让它与底部的标签页一起使用。 我的代码是Xaml 表单:在ContentPage中不可见工具栏项,xaml,xamarin.forms,toolbaritems,Xaml,Xamarin.forms,Toolbaritems,我正在为我的项目使用Xamarin.Forms&我需要在页面顶部有工具栏。 我试图让它与底部的标签页一起使用。 我的代码是 <?xml version="1.0" encoding="utf-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:edTheSIS"
x:Class="edTheSIS.ParentDashboard">
<ContentPage.ToolbarItems>
<ToolbarItem Name="MenuItem1" Order="Primary" Text="Item 1" Priority="0" />
<ToolbarItem Name="MenuItem2" Order="Primary" Text="Item 2" Priority="1" />
</ContentPage.ToolbarItems>
<AbsoluteLayout>
<StackLayout BackgroundColor="Teal" AbsoluteLayout.LayoutBounds="0, 5, 0, 0" AbsoluteLayout.LayoutFlags="All">
<StackLayout Margin="0,200,0,0" HorizontalOptions="Center">
<Label Text="Xamarin.Forms" HorizontalTextAlignment="Center" TextColor="White"></Label>
<Label Text="Bottom NavigationBar" HorizontalTextAlignment="Center" TextColor="White"></Label>
</StackLayout>
</StackLayout>
<StackLayout AbsoluteLayout.LayoutBounds=".20,1,1,.1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="White" HorizontalOptions="FillAndExpand" Orientation="Horizontal">
<StackLayout Style="{StaticResource ButtonNavigationBarStackLayoutStyle}" x:Name="stckHome">
<Image Margin="0,10,0,10" x:Name="imgHome" Style="{StaticResource ButtonNavigationBarImageStyle}" />
<Label Text="Dairy" Style="{StaticResource ButtonNavigationBarLabelStyle}"></Label>
</StackLayout>
<StackLayout Style="{StaticResource ButtonNavigationBarStackLayoutStyle}" x:Name="stckAlarm">
<Image Margin="0,10,0,10" x:Name="imgAlarm" Style="{StaticResource ButtonNavigationBarImageStyle}" />
<Label Text="Alarm" Style="{StaticResource ButtonNavigationBarLabelStyle}"></Label>
</StackLayout>
</StackLayout>
</AbsoluteLayout>
</ContentPage>
执行代码后,只显示选项卡,而不显示工具栏项。将页面包装在
导航页面中
我猜您现在正在App.xaml.cs
中设置MainPage
,例如:MainPage=newparentdashboard()代码>
将其设置为:MainPage=newnavigationpage(newparentdashboard())
正如您所说,我将主页保持为ParentDashboard()
并获取ToolbarItems
,但现在我没有获取作为我应用程序第一页的登录页。我在MainPage.xaml
中有登录用户界面。然后,无论何时从登录页面切换到仪表板页面,都将其包装在导航页面中。我知道了。你是天才。