Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Hide the toolbar items in windows phone with xamarin forms

$
0
0

Hello

I have a class that inherits fomr contentPage, that contains a ToolbarItem:

if (Device.OS == TargetPlatform.WinPhone)
            {
                toolbarItem = new ToolbarItem("Add", "add.png", () =>
                {
                }, 0, 0);
            }

            ToolbarItems.Add(toolbarItem); 

In my OnAppearing and OnDissapearing methods i have:

protected override void OnAppearing()
        {
            base.OnAppearing();
            SetToolbarItems(true);
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            SetToolbarItems(false);
        }

private void SetToolbarItems(bool show)
        {
            if (Device.OS != TargetPlatform.WinPhone)
                return;

            if (show)
            {
                ToolbarItems.Add(toolbarItem);
            }
            else
            {
                ToolbarItems.Remove(toolbarItem);
                ToolbarItems.Clear();
            }
        }

The toolbar items appear when I navigate to this view but when I go back to my mainView (which is a view that also inherits from contentPage) the toolbaritems bar is still there is still showed, How can I hide the toolbar?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>