假設在調用AddBindings之前初始化了bar按鈕 - MyButton,那麼我認爲你的代碼應該可以工作。
我修改了代碼中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
被調用,但某種程度上失敗 - 這可能會發生的東西,如電子郵件,PhoneCalls,推文等,這些並不總是在模擬器上工作。
謝謝@Stuart。它也適用於我。我的'MvxCommand'的'canExecute'部分返回false:/ – 2013-03-04 14:11:15
Mvx現在不做的一件事是處理canExecute以在任何控件上啓用綁定 - 這可以繞過使用單獨的啓用/禁用屬性,但不是'完美。 – Stuart 2013-03-04 15:15:41