【发布时间】:2019-03-14 11:44:23
【问题描述】:
Xamarin 新手,我正在尝试在我的跨平台应用程序中创建自定义导航栏。经过一番阅读,我发现我可以在我的 xaml 页面文件中使用 title-view 组件,如下所示。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="amici.MyGroups">
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal" VerticalOptions="Center" Spacing="10">
<Label HorizontalOptions="StartAndExpand" Text="Left"/>
<Label HorizontalOptions="CenterAndExpand" Text="Center"/>
<Label HorizontalOptions="EndAndExpand" Text="Right"/>
</StackLayout>
</NavigationPage.TitleView>
<ContentPage.Content>
<ScrollView>
<Grid x:Name="grid1">
<StackLayout>
<Label Text="Welcome"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
<ActivityIndicator x:Name="WaitIcon" IsRunning="{Binding IsBusy}" VerticalOptions="Center" HorizontalOptions="Center" />
</Grid>
</ScrollView>
</ContentPage.Content>
</ContentPage>
我像这样导航到我的页面“MyGroups”:Navigation.PushAsync(new MyGroups());.
但是,唯一显示的是带有后退图标箭头的默认导航页面?
不知不觉我错过了一些东西,或者我不明白一些东西。这需要在应用程序级别完成吗?
【问题讨论】:
-
您可以为
NavigationPage设置自定义TitleView将导航事件更改为Navigation.PushAsync(new NavigationPage(new MyGroups()));,您现在可以看到您的自定义标题视图了吗? -
@Evz 抱歉,但只知道带有默认后退箭头的默认栏。
-
定位平台是什么?
-
@Evz 现在是的(我在错误的位置更改了呼叫)但是现在我有两个导航栏,一个带有箭头,一个带有我的标题视图。如果我设置 NavigationPage.HasNavigationBar="false" 那么我只得到默认的并且标题视图不显示。我需要对此进行更多阅读,因为我似乎不明白 LOL 发生了什么。
-
我将尝试通过将我的评论转换为正确答案来指导您。
标签: xaml xamarin xamarin.forms