为什么<NavigationPage.TitleView>在TabbedPage中不起作用?

问题描述

 <NavigationPage >
        <x:Arguments>
            <controls:TabIconsPage/>
        </x:Arguments>
        <NavigationPage.TitleView>
            <StackLayout Orientation="Horizontal">
                <ImageButton Source="Taxi.png" WidthRequest="50" HeightRequest="50" HorizontalOptions="EndAndExpand"/>
            </StackLayout>
        </NavigationPage.TitleView>
    </NavigationPage>
    <NavigationPage>
        <x:Arguments>
            <controls:TabIconsPage/>
        </x:Arguments>
        <NavigationPage.TitleView>
            <StackLayout Orientation="Horizontal">
                <ImageButton Source="Taxi.png" WidthRequest="50" HeightRequest="50" HorizontalOptions="EndAndExpand"/>
            </StackLayout>
        </NavigationPage.TitleView>
    </NavigationPage>

我想在标签栏中创建一个带有不同图像的选项卡式页面,但是它不起作用。请帮忙。我想制作不同尺寸的图像

enter image description here

我想要什么

enter image description here

我有什么

enter image description here

enter image description here

我想要在第一个屏幕上,并更改图标的大小

解决方法

为什么在TabbedPage中不起作用?

TitleView应该在每个特定的ContentPage中而不是TabbedPage中设置。因此,在页面中,您应该在controls:TabIconsPage中配置TitleView:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="controls:TabIconsPage">
    
    <NavigationPage.TitleView>

            <StackLayout Orientation="Horizontal">
            <ImageButton Source="Taxi.png" WidthRequest="50" HeightRequest="50" HorizontalOptions="EndAndExpand"/>
            <ImageButton Source="Taxi.png" WidthRequest="50" HeightRequest="50" HorizontalOptions="EndAndExpand"/>
            <ImageButton Source="Taxi.png" WidthRequest="50" HeightRequest="50" HorizontalOptions="EndAndExpand"/>
        </StackLayout>
    </NavigationPage.TitleView>
        ...
</ContentPage>

如何更改图标的大小?

尝试使用较小的图标或将WidthRequest / HeightRequest设置为较小的值。