问题
I'm trying to build a MonoGame view inside MvvmCross on Android,iOS and WP8. On Windows side it's relatively easy to use dependency properties as a binding target, but how can I achieve a cross platform data binding solution that I can use on all platform?
回答1:
This was covered in a previous MvvmCross version - see Insert a Monogame view inside MvvmCross monodroid Activity
The technical details have changes a bit since that post, but the core of the advice remains the same - use inheritance to add data-binding.
For example, if you want to adapt a FooActivity
or FooViewController
base class so that it can be used for MvvmCross data-binding, then you need to:
- inherit from
FooActivity
to provideEventSourceFooActivity
- to do this you need to add event notifications like those shown in MvxEventSourceFragmentActivity.cs - inherit from
EventSourceFooActivity
to provideBindingFooActivity
- to do this you need to add all the members likeDataContext
from MvxFragmentActivity.cs
The process for Touch/iOS is very similar, but with iOS specific events and members. Take a look at any of the Mvx*ViewController
classes to see what is involved.
This technique is also discussed in: Integrating Google Mobile Analytics with MVVMCross
来源:https://stackoverflow.com/questions/17316092/mvvmcross-monogame