ToolbarItem are not shown

axbeitaxbeit Member ✭✭
edited November 2018 in Xamarin.Forms

Hey there.

Im currently working myself trough this book

On Page 34/35 there is an example code that I copied. My problem is that no ToolbarItem s are shown. Neither the ones with an image and 'Order="Primary"' nor the ones without an image and 'Order="Secondary"' and I cannot find a way to fix this.

I tried to find a way for the ToolbarItem s with an Image like "edit.png" for example. I put in a 25x25 Image in the Resources folder for it but that does not seem to fix it either.

    <?xml version="1.0" encoding="utf-8"?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
                 xmlns:local="clr-namespace:BookCode" 
                 x:Class="BookCode.MainPage"
                 Title="Visuals">


        <StackLayout Padding="10,0">
            <Label Text="Hello, Xamarin.Forms!"
                   FontSize="Large"
                   VerticalOptions="CenterAndExpand"
                   HorizontalOptions="Center"/>

            <Button Text="Click Me!"
                    VerticalOptions="CenterAndExpand"
                    HorizontalOptions="Center"/>

            <Switch VerticalOptions="CenterAndExpand"
                    HorizontalOptions="Center"/>
        </StackLayout>

        <ContentPage.ToolbarItems>
            <ToolbarItem Text="edit" Order="Primary">
                <ToolbarItem.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource"
                                iOS="edit.png"
                                Android="ic_action_edit.png"
                                WinPhone="Images/edit.png"/>  
                </ToolbarItem.Icon>
            </ToolbarItem>

            <ToolbarItem Text="search" Order="Primary">
                <ToolbarItem.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource"
                                iOS="search.png"
                                Android="ic_action_search.png"
                                WinPhone="Images/feature.search.png"/>
                </ToolbarItem.Icon>
            </ToolbarItem>

            <ToolbarItem Text="refresh" Order="Primary">
                <ToolbarItem.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource"
                                iOS="reload.png"
                                Android="ic_action_refresh.png"
                                WinPhone="Images/refresh.png"/>
                </ToolbarItem.Icon>
            </ToolbarItem>

        <ToolbarItem Text="explore" Order="Secondary"/>
        <ToolbarItem Text="discover" Order="Secondary"/>
        <ToolbarItem Text="evolve" Order="Secondary" />
    </ContentPage.ToolbarItems>
</ContentPage>

Best Answer

Answers

  • dinesh314850dinesh314850 Member ✭✭

    @axbeit put your toolbaritem code above stack layout and run project. i hope this might be help you.

  • axbeitaxbeit Member ✭✭

    @dinesh314850 said:
    @axbeit put your toolbaritem code above stack layout and run project. i hope this might be help you.

    sadly this did not work.

  • stemadostemado Member ✭✭✭
    edited November 2018

    This could simply be that it didn't get copied over in to your example, but you are missing your closing </ContentPage> tag in your example.

  • axbeitaxbeit Member ✭✭
    edited November 2018

    @stemado said:
    This could simply be that it didn't get copied over in to your example, but you are missing your closing </ContentPage> tag in your example.

    Oh yes, sorry.
    In my xaml it is not missing. I just havent selected it when copying it here.

    edit
    Oh I actually copied it over here. It was just missing here. Some format error I guess. Fixed it

  • stemadostemado Member ✭✭✭

    @axbeit can you upload your project and I can take a look when I get back home shortly.

  • axbeitaxbeit Member ✭✭
    edited November 2018

    @stemado said:
    @axbeit can you upload your project and I can take a look when I get back home shortly.

    Thank you, I appreciate your help :) - sorry for the late answer. I hope you still find some time.

    https://ufile.io/frj89

Sign In or Register to comment.