Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data Binding Order of Operations for Caliburn Micro Xamarin

What is the "Order of Operations" (OOP) for Data Binding in Caliburn.Micro Xamarin Android (Mono.Android)?

PS: a tutorial that explains/compares how binding occurs in Caliburn Micro Standard/WPF, Caliburn Micro Android & Caliburn Micro iOS (ie Caliburn.Micro Xamarin) would be very useful and a nice introduction into Caliburn Micro Xamarin.

For regular Caliburn.Micro the OOP for Binding is (correct me if I am wrong):

  • Declare Field in ViewModel
  • On Field Set: call NotifyOfPropertyChange(..)
  • Bind View to ViewModel using the XAML attribute x:Name

I've inspected the example projects Hello.Xamarin and HubBrowser and I think I have a bit of an idea how it works but it looks like there is ALOT of setup required. For Caliburn.Micro Xamarin Android is the Binding OOP something like...?

  • Extend the NotifyPropertyChanged method. Not sure why...maybe so it works for Android? We produce a static class called NotifyPropertyChangedExtensions
  • Declare Field in ViewModel (same as standard CM)
  • On Field Set: call NotifyOfPropertyChange(..) (same as standard CM)
  • Give all View widgets a unique id android:id
  • On View (Activity) creation: bind View widgets to ViewModel Fields somehow??
like image 652
sazr Avatar asked Nov 09 '22 06:11

sazr


1 Answers

Essentially the OOP you have indicated for the Windows flavor of binding occurs under the hood, the system is ViewModel first meaning everything starts with a viewmodel from there we look to see if we have a View with the same namespace and name. If we find it, great, now mash them together with a binding operation essentially setting the Datacontext of the view with the instance of the viewmodel. Otherwise, fail give the resultant screen a default blank stare back at you :(.

Since the stuff associated with binding in Xamarin / Native is slightly different hence some of the features will probably come at a later date with more tutorials / samples as people get a chance to road test the code.

Link has some of the stuff yet to complete and stuff that is complete with explanations as to why or why not. https://github.com/Caliburn-Micro/Caliburn.Micro/issues/142

like image 103
mvermef Avatar answered Nov 15 '22 11:11

mvermef