我正在处理Xamarin表单,我需要在导航面板右侧显示按钮。
按钮正在显示,但是当我点击它时,它没有触发Activated
或Clicked
事件。
这是XAML:
<ContentPage.ToolbarItems>
<ToolbarItem Name="Save" Activated="SaveClicked" Clicked="SaveClicked" Order="Primary" Priority="0" />
</ContentPage.ToolbarItems>
背后的代码是:
public EditDepartureChecklist()
{
InitializeComponent();
this.Title = Application.Current.Properties["VesselName"].ToString();
NavigationPage.SetBackButtonTitle(this, "");
//var saveItem = new ToolbarItem
//{
// Text = "Save"
//};
//this.ToolbarItems.Add(saveItem);
//saveItem.SetBinding(MenuItem.CommandProperty, "SaveClicked");
}
public void SaveClicked(object sender, EventArgs e)
{
var data = _selectedChecklistForm;
}
答案 0 :(得分:-1)
public partial class CPage_Perfil : ContentPage
{
//Constructors
public CPage_Perfil()
{
InitializeComponent();
NavigationPage.SetHasBackButton(this, true);
Title = "PERFIL";
this.ToolbarItems.Add(new ToolbarItem
{
Icon = "Editarmdpi.png",
Name = "Editar",
Command = new Command(() => DisplayAlert("Selected", "menu1", "OK"))
});
}