Search code examples
c#xamlxamarinxamarin.formsxamarin.android

Why <NavigationPage.TitleView> does not work in 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>

I want to make a tabbed page with different images in tabbar but it does not work.Please help.I want to make different size of images

enter image description here

what I want

enter image description here

what I have

enter image description here enter image description here

I want like on the first screen and change size of icons


Solution

  • Why <NavigationPage.TitleView> does not work in TabbedPage?

    TitleView should be set in each specific ContentPage instead of in TabbedPage. So in your page, you should config the TitleView in controls:TabIconsPage:

    <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>
    

    How can I change the size of icon?

    Try to use a icon with small size or set the WidthRequest/HeightRequest with a smaller value.