Dynamic UIWebView binding in MVVMCross

I am trying to make changes to the sample Cirrious.Conference project. In particular, in Touch View in the SessionView class and in this class

https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20CirriousConference/Cirrious.Conference.Core/ViewModels/SessionLists/BaseSessionListViewModel.cs

according to the method

protected void NavigateToSession(Session session)
{
 ShowViewModel<SessionViewModel>(new { key = session.Key });
}

I would like to open the UIWebView (in the application) binding of LoadRequest with a property of the Session class (suppose the URL of the property ...). I created a UIWebView object in SessionView, but could not create a Swisse Binding ... Perhaps this is possible with customBinding ...

How can i do this?

+1
source share
1 answer

UIWebView LoadRequest, .

LoadRequest, 3 :

  • MyWebView UIWebView #, LoadRequest, - :

        [Register("MyWebView")]
        public class MyWebView : UIWebView
        {
            public MyWebView()
            {
            }
    
            public MyWebView(IntPtr handle) : base(handle)
            {
            }
    
            private string _myUrl;
            public string MyUrl
            {
                get { return _myUrl; }
                set
                {
                   if (_myUrl == value) return;
                   _myUrl = value;
                   LoadRequest(value); // or similar (I've not checked the syntax!)
                }
            }
        }
    
  • Swiss Swiss Setup.cs. Custom Bindings, ( )

  • , LoadRequest MvxViewController ViewDidLoad - .

         public void ViewDidLoad()
         {
             base.ViewDidLoad();
    
             var myViewModel = (MyViewModel)ViewModel;
             var url = myViewModel.Url;
             TheWebView.LoadRequest(url);
         }
    
+5

All Articles