假设条形按钮 - MyButton - 在您调用 AddBindings 之前已初始化,那么我认为您的代码应该可以工作。
我将会议示例中 WelcomeView 中的代码修改为下面的代码,它似乎可以工作......
var s = new UIBarButtonItem()
{
Title = "Click me"
};
NavigationItem.SetRightBarButtonItem(s, false);
this.AddBindings(new Dictionary<object, string>()
{
{ Button1, "TouchUpInside ShowSponsorsCommand" },
{ Button2, "TouchUpInside ShowExhibitorsCommand" },
{ Button3, "TouchUpInside ShowMapCommand" },
{ Button4, "TouchUpInside ShowAboutCommand" },
{ s, "Clicked ShowMapCommand" },
});
//NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Tweet", UIBarButtonItemStyle.Bordered, (sender, e) => ViewModel.DoShareGeneral()), false);
抱歉,如果这个“它对我有用”的答案对您的机器没有帮助:/
为了确保它在发布模式下工作,您可能需要在UIBarButtonItem.Clicked
某处添加一些代码。
如果您想从绑定中获得更多跟踪,那么您可以设置一个诊断跟踪级别(但这可能会变得非常冗长)。
可能值得检查您MyCommand
是否被呼叫但不知何故失败 - 这尤其可能发生在电子邮件、电话、推文等并不总是在模拟器上工作的事情上。