Data Binding Order of Operations for Caliburn Micro Xamarin

巧了我就是萌 提交于 2019-12-10 14:33:32

问题


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??

回答1:


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



来源:https://stackoverflow.com/questions/32152131/data-binding-order-of-operations-for-caliburn-micro-xamarin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!