Forum Xamarin Cross Platform with Xamarin

How to use MvxFragment in MvvmCross?

I have created a MvxFragment as;

using MvvmCross.Droid.Views.Attributes;
using MvvmCross.Droid.Views.Fragments;

namespace FragmentMvvm.Droid.Fragments
    [MvxFragmentPresentation(typeof(MainViewModel), Resource.Id.fragment_container)]
    public class NormalFragment : MvxFragment<SubViewModel>
        public override void OnCreate(Bundle savedInstanceState)

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            return inflater.Inflate(Resource.Layout.NormalFragment, container, false);

Most of the guide in the internet use MvxFragment instead of MvxFragmentPresentation. If I use MvxFragment, I get 'MvxFragment' is not an attribute class error. So, I used MvxFragmentPresentation. Is this the correct way? Is this something that changed in MvvmCross 5?

I also tried using this.BindingInflate() but I am not able to access BindingInflate. It appears that it does not exist. The fragment loads but data binding does not work inside a fragment. I am new to MvvmCross. What am I missing?

I am using latest version of MvvmCross(5.6.3).


  • FabricioBertaniFabricioBertani USMember ✭✭✭

    Did you set a base Activity for your fragment?

  • ThomasLambThomasLamb USUniversity ✭✭

    Do you have any comments on creating this MvvmCross 5? From the documentation and reading (Xamarin In Action), it looks like v5 is more agnostic using Views and ViewModels rather than the android-centric Activity.

Sign In or Register to comment.