Search code examples
androidxamarinxamarin.androidmvvmcross

MvvmCross Android UI components


I've made Android apps using pure Xamarin.Android, and now I'm starting a new Xamarin.Android project using MvvmCross with it. I noticed MvvmCross comes with some of its own UI components (like MvxListView) that I should be using instead of the pure Android UI component. Is there a list of these MvvmCross Android components that I can use as a reference, to make sure that I am using MvvmCross properly?

I want to start my Android app by making tabs at the bottom of the screen. Is there a "MvvmCross way" of doing this? Or should I still use the pure Android UI components that I usually use (ViewPager and TabLayout)?

Any advice for someone going to MvvmCross from pure Xamarin.Android would be appreciated as well!


Solution

  • The Views MvvmCross provides are simply to provide bindings. So in the case of ListView, instead of having to create your own Adapter for a ListView and assign that in your Activity or Fragment, you can bind it like so in the layout:

    local:MvxBind="ItemsSource MyItems"
    

    Where MyItems is a collection of items in your ViewModel. The underlying control is still ListView and you would be able to cast a MvxListView directly to ListView if you really wanted.