ios - Bind to UIBarButtonItem events in MvvmCross -
what's proper way mvvmcross
create binding uibarbuttonitem
mvxcommand
?
this not work me ->
public override void viewdidload () { base.viewdidload (); this.addbindings (new dictionary<object, string> (){ {mybutton, "{'clicked':{'path':'mycommand'}}"} }); }
i don't error in console. can work around avoiding bindings, know, it'd best if bound.
assuming bar button - mybutton - initialized before call addbindings, think code should work.
i modified code in welcomeview in conference sample below , seems work...
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);
sorry if 'it works me' answer doesn't on machine :/
to ensure works in release mode, might need add uibarbuttonitem.clicked
code somewhere.
if want more trace bindings, there diagnostic trace level can set (but can quite verbose).
it might worth checking if mycommand
being called somehow failing - can happen things email, phonecalls, tweets, etc don't work on simulator.
Comments
Post a Comment