微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决为什么<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设置为较小的值。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。