1

I'm using Visual Studio 2015 and made a Xamarin project to support iOS, Android and UWP.

I want rebrand the toolbar, and on iOS and Android its possible to set a background color and a picture in the toolbar.

But for Universal Windows Platform this seems impossible.

So I want to set my own TopAppBar with a picture, and hide the current toolbar for UWP;

In my MainPage.xaml.cs I've;

#if __ANDROID__ || __IOS__             

            ToolbarItems.Add(new ToolbarItem("+", "", () => App.Navigation.PushAsync(new AddAccount())));

#endif 

So for UWP there would be no items on the toolbar. But it still appears.

I cannot find any documentation on how to; -customize the toolbar for UWP -hide the toolbar for UWP

I've tried to add a toolbar like so;

    var _globalAppBar = new AppBar();

    _globalAppBar.Height = 128;

    _globalAppBar.Background = new SolidColorBrush(Colors.Green);

    BitmapImage bmI = new BitmapImage();
    bmI = new BitmapImage(new Uri("ms-appx:///Assets/logo.png", UriKind.RelativeOrAbsolute));

    var imageBrush = new ImageBrush();
    imageBrush.ImageSource = bmI;
    _globalAppBar.Background = imageBrush;

    AppBarButton abbtn = new AppBarButton();
    abbtn.Label = "Add";

    _globalAppBar.Content = abbtn;

    this.BottomAppBar = _globalAppBar;

But that results in having two toolbars at the top...

So it's better to modify the existing toolbar created by Xamarin, but I don't know how to access it from the 'public MainPage()' of the UWP project.

4

1 回答 1

2

I just tried to redo your problem. I can hide the toolbar when I clear the toolbaritems. Also I have to call

NavigationPage.SetHasNavigationBar(this, false);

on the page.

于 2016-04-25T00:29:38.313 回答