Mik*_*ike 4 xaml xamarin xamarin.forms
Xamarin 新手,我正在尝试在我的跨平台应用程序中创建自定义导航栏。经过一些阅读,我发现我可以在我的 xaml 页面文件中使用标题视图组件,如下所示。
<?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>
Run Code Online (Sandbox Code Playgroud)
我导航到我的页面“MyGroups”,如下所示:Navigation.PushAsync(new MyGroups());。
但是,唯一显示的是带有后退图标箭头的默认导航页面?
显然我错过了一些东西,或者我不明白一些东西。这是否需要在应用程序级别完成?
如果你在你的Xamarin.Forms应用程序中使用壳牌比你将不得不使用<Shell.TitleView>替代<NavigationPage.TitleView>。下面的代码对我有用...
<Shell.TitleView>
    <Label Text="QR Code" HorizontalTextAlignment="End" Margin="0,0,10,0" Padding="0" VerticalTextAlignment="Center" TextColor="White" FontSize="20"/>
</Shell.TitleView>
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           4274 次  |  
        
|   最近记录:  |