mvvm - Dynamic Binding UIWebView in MVVMCross -
i'm trying make change sample project cirrious.conference. in particular in touch view @ sessionview class , @ class
on method
protected void navigatetosession(session session) { showviewmodel<sessionviewmodel>(new { key = session.key }); }
i'd openl uiwebview (in app) binding loadrequest property of class session (suppose have property url...). have created uiwebview object in sessionview it's not possible create swisse binding...maybe it's possible custombinding...
how i'll it?
since uiwebview
doesn't expose property loadrequest
, can't bind directly it.
if want use binding loadrequest
, 3 options available are:
inherit
mywebview
uiwebview
, add c# property drivesloadrequest
, use class in ui , property in swiss binding - e.g.:[register("mywebview")] public class mywebview : uiwebview { public mywebview() { } public mywebview(intptr handle) : base(handle) { } private string _myurl; public string myurl { { return _myurl; } set { if (_myurl == value) return; _myurl = value; loadrequest(value); // or similar (i've not checked syntax!) } } }
implement custom target swiss binding , add setup.cs. process described in custom bindings presentation - includes links examples (one of them in conference app)
if property never change, don't use binding , instead call loadrequest in
mvxviewcontroller
viewdidload - e.g.public void viewdidload() { base.viewdidload(); var myviewmodel = (myviewmodel)viewmodel; var url = myviewmodel.url; thewebview.loadrequest(url); }
Comments
Post a Comment