【发布时间】:2016-08-17 14:30:00
【问题描述】:
我正在使用 Visual Studio 2015 并制作了一个 Xamarin 项目来支持 iOS、Android 和 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项目的'public MainPage()'访问它。
【问题讨论】:
标签: xamarin win-universal-app toolbar commandbar