0
我使用Visual Studio 2015并制作了一个Xamarin项目来支持iOS,Android和UWP。Xamarin UWP品牌工具栏
我想重新命名工具栏,并且在iOS和Android上可以在工具栏中设置背景颜色和图片。
但对于通用Windows平台,这似乎是不可能的。
所以我想用图片设置我自己的TopAppBar,并隐藏UWP的当前工具栏;
在我的MainPage.xaml.cs中,
#if __ANDROID__ || __IOS__
ToolbarItems.Add(new ToolbarItem("+", "",() => App.Navigation.PushAsync(new AddAccount())));
#endif
因此,对于UWP,工具栏上没有任何项目。但它仍然出现。
我找不到任何有关如何操作的文档; - 为UWP定制工具栏 - 隐藏UWP的工具栏
我尝试添加一个像这样的工具栏;
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;
但是,这导致在顶部有两个工具栏...
所以最好修改由Xamarin创建的现有工具栏,但我不知道如何从“公共访问UWP项目的MainPage()'。
太好了,谢谢,那就是我一直在寻找的! :)你在哪里找到这个? – Lectere
我的猜测:https://developer.xamarin.com/api/member/Xamarin.Forms.NavigationPage.SetHasNavigationBar/ :) – DdW