Search code examples
xamarinmvvmcrossxamarin.droid

Custom Animation with MvvmCross Droid


With MvvmCross, if I want a button to open a new screen, I wire up the command handler and use ShowViewModel, like this:

        ShowViewModel<InfoViewModel>();

Is there anyway to plug in custom animations, which are very platform specific, and still use ShowViewModel in the core? If I were doing this in a Droid project, it would look like this:

        OverridePendingTransition(Resource.Animation.push_up_in, Resource.Animation.push_up_out);

So basically I want a way to hook into the MvvmCross Activity creation from the Droid project.


Solution

  • Solved by calling the command from the MvxActivity in the UI.

            var infoBtn = FindViewById<RelativeLayout>(Resource.Id.infobtn);
            infoBtn.Click += delegate(object sender, EventArgs args)
                {
                    ((MainMenuViewModel)ViewModel).InfoCommand.Execute(null);
                    OverridePendingTransition(Resource.Animation.push_up_in, Resource.Animation.push_up_out);                 
                };