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