Xamarin UWP 品牌工具栏
Xamarin UWP brand toolbar
我正在使用 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()'访问它。
我只是想重做你的问题。我可以在清除工具栏项时隐藏工具栏。
我还必须打电话给
NavigationPage.SetHasNavigationBar(this, false);
在页面上。
我正在使用 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()'访问它。
我只是想重做你的问题。我可以在清除工具栏项时隐藏工具栏。 我还必须打电话给
NavigationPage.SetHasNavigationBar(this, false);
在页面上。