xamarin - MvvmCross no bindings created -
i upgraded project older version of mvvmcross latest version, , i'm having trouble bindings.
i'm aware of linkerpleaseinclude hack, , looks (at least of) properties i'm using listed there.
i'm concerned usage of views , viewmodels. here's example.
public partial class homeview : mvxviewcontroller<homeviewmodel> ... public override void viewdidload () { base.viewdidload(); this.createbinding(budgettrackerbutton).to((homeviewmodel vm) => vm.budgettracker).apply(); this.createbinding(loginbutton).for("title").to ((homeviewmodel vm) => vm.logmessage).apply(); this.createbinding(loginbutton).to((homeviewmodel vm) => vm.login).apply(); this.createbinding(contactapprisenbutton).to((homeviewmodel vm) => vm.contact).apply(); this.createbinding(aboutapprisenbutton).to((homeviewmodel vm) => vm.about).apply(); this.createbinding(aboutthisappbutton).to((homeviewmodel vm) => vm.aboutapp).apply(); this.createbinding(faqsbutton).to((homeviewmodel vm) => vm.faqs).apply(); this.createbinding(privacypolicybutton).to((homeviewmodel vm) => vm.privacypolicy).apply(); } public abstract class mvxviewcontroller<t> : uiviewcontroller, imvxbindingcontextowner, iuiwrappable, mvvmcross.ios.views.imvxiosview t : viewmodelbase ... } protected mvvmcross.core.viewmodels.imvxviewmodel _viewmodel = null; public mvvmcross.core.viewmodels.imvxviewmodel viewmodel { { if (_viewmodel == null) { _viewmodel = mvvmcross.platform.mvx.resolve<t> (); } return _viewmodel; } set { _viewmodel = value; } } public mvvmcross.core.viewmodels.mvxviewmodelrequest request { get; set; } public object datacontext { { return _viewmodel; } set { _viewmodel = (mvvmcross.core.viewmodels.imvxviewmodel)value; } } protected mvvmcross.binding.bindingcontext.imvxbindingcontext _bindingcontext; public imvxbindingcontext bindingcontext { { if (_bindingcontext == null) { _bindingcontext = new mvvmcross.binding.bindingcontext.mvxbindingcontext (); } return _bindingcontext; } set { _bindingcontext = value; } }
createbinding mvxbindingcontextownerextensions.
when hit createbinding, view model has been made.
i understand datacontext same viewmodel, , include conform mvvmcross.ios.views.imvxiosview
interface.
am missing step somewhere? interface?
matching views view models should happen automatically based on naming conventions, right? (they didn't.. in case, had manually specify mappings in setup class. contributing problem.)
strangely enough, works (for button title anyway, haven't tested other bindings, , i'm not interested in updating bindings across entire application if fix simple):
var set = this.createbindingset<homeview, homeviewmodel>(); set.bind(loginbutton).for("title").to(vm => vm.logmessage);
i can post more code if else relevant. i'm new mvvmcross.
Comments
Post a Comment