我有一个内容页面,工具栏添加如下:
内容页面
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ChartList : ContentPage
{
public ChartList ()
{
InitializeComponent ();
//public class ToolbarItem : MenuItem
ToolbarItem settings = new ToolbarItem
{
Icon = "icon.png",
Text = "Settings",
Command = new Command(this.ShowHomePage),
};
this.ToolbarItems.Add(settings);
}
private void ShowHomePage()
{
this.Navigation.PushAsync(new MainPage());
}
}
App.Xaml.cs
public App()
{
InitializeComponent();
ContentPage p = new MyHomeScreen2.MainPage();
MainPage = new NavigationPage(p)
{
BarBackgroundColor = Color.Purple,
BarTextColor = Color.White
};
}
我需要将工具栏上的图标居中对齐。在Xamarin Forms中如何实现?