MvvmCross 6.0

Announcing MvvmCross 6.0!

Yes, you read it correctly! MvvmCross 6 has finally arrived and it is available on NuGet!

What’s new?!

  • Migration to .NET Standard 2
  • Polished support for Xamarin.Forms
  • Brand new framework initialization (Setup & AppStart)
  • New register process for plugins
  • Supercharged IMvxOverridePresentationAttribute for ViewPresenters
  • Initial support for Tizen
  • Tons of improvements and bug fixes!

Migration guide

MvvmCross 6 comes with quite a lot of improvements, but this also means some things will break. We have prepared a migration guide that will help you do the transition real quick! You can find it here.

NuGet packages

With MvvmCross 6 there are some changes to the NuGet packages. The following packages are obsolete and included in the main MvvmCross package:

  • MvvmCross.Core
  • MvvmCross.Platform
  • MvvmCross.Binding

NuGet packages are now versioned using SemVer 2.0, meaning you need to use Visual Studio 2017 (15.3) and above or NuGet 4.3.0 and above.

The MvvmCross.* namespace has been reserved on NuGet, meaning that plugin authors should move their plugins away from this package namespace. We are also planning on signing future releases.

.NET Standard

MvvmCross uses .NET Standard 2.0 as its base library now. This ensures compability on all platforms, and helps us develop MvvmCross faster!

For a explanation about .NET Standard see: https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/

Setup & platforms initialization

We’ve changed the way platforms are loaded. Previously you had to create the Setup class in every platform yourself (except for Android if you were using a Splashscreen). Starting with v6 the Setup class has received a lot of improvements! Also if you are starting with a brand new application, you might not even need to write your own!

In order to avoid having to create and initialize the Setup class yourself, you can now use generic versions of some classes:

  • On iOS, there’s a version of MvxApplicationDelegate which takes a IMvxIosSetup and a IMvxApplication constraints
  • On Android, there’s a version of MvxAndroidApplication which takes a MvxAndroidSetup and a IMvxApplication constraints
  • On Android (support packages), there’s a version of MvxAppCompatApplication which takes a MvxAppCompatSetup and a IMvxApplication constraints
  • On UWP, there’s a version of MvxApplication which takes a MvxWindowsSetup and a IMvxApplication constraints
  • On WPF, there’s a version of MvxApplication which takes a MvxWpfSetup and a IMvxApplication constraints
  • On macOS, there’s a version of MvxApplicationDelegate which takes a MvxMacSetup and a IMvxApplication constraints
  • On tvOS, there’s a version of MvxApplicationDelegate which takes a MvxTvosSetup and a IMvxApplication constraints

A few importatant notes on this are:

  • On iOS, tvOS and macOS please make sure you are calling var result = base.FinishedLaunching(app, options); and returning the result at the end of the method.
  • Remove custom App.cs code from your UWP and WPF projects
  • On Android this initialization also works for apps without splash screens.
  • Of course you can keep your Setup class if you want (and it is still encouraged to initialize everything there)!
  • There is now also a singleton for Setup on all platforms, which you can use to ensure MvvmCross is running!

The main work on all this changes was done by @nickrandolph and @martijn00. Well done guys!

AppStart

The way apps start with MvvmCross has now become much cleaner. MvxAppStart is now called automatically by the framework uniformly. This means you can safely delete your initialization code on platforms like iOS (the framework now will also create the key window for you).

In case you are using a custom AppStart, it is recommended that you make it inherit from the newly added MvxAppStart class.

If you are wondering now whether it’s possible to add some customization to that, the answer is YES. In the same class where you used to run your own AppStart, there is now a virtual method called RunAppStart that you can override. And going further on that direction, if what you need is to make sure you provide a correct hint to your AppStart, then you only need to override the new method called GetAppStartHint. Sweet, ah? All thanks to the MvvmCross Core Team.

Note: In case you have a custom AppStart, watch out! The method Start has been made protected and it’s now called Startup.

Plugins

No more bootstrap files! Yes, you read it correctly. @willsb has worked hard on plugins during some time and he came out with an easier way to register your MvvmCross plugins, by simply adding the [MvxPlugin] attribute to your plugin and inheriting from IMvxPlugin - as usual -.

The way plugins are loaded has improved as well, and now you can force them to be loaded again and even see which ones are loaded at a given time through IMvxPluginManager.LoadedPlugins.

Read more about how to get started with plugins in our documentation.

Json and Resx plugins

All methods in MvxResxTextProvider, MvxJsonDictionaryTextProvider and MvxTextProvider are now virtual. Customization is now much easier!

DownloadCache

DownloadCache was removed in v6.0, as well as MvxImageView and all the related code.

ViewPresenters

IMvxOverridePresentationAttribute.PresentationAttribute now takes a MvxViewModelRequest as parameter. As a result, when the method PresentationAttribute is called, you will be able to make your choice on which attribute to use taking advantage of the ViewModel request. But that’s not everything! If you are using the MvxNavigationService, you can cast the arriving parameter of type MvxViewModelRequest to be a MvxViewModelInstanceRequest, which will allow you to see the ViewModel that is being presented. This change was made by @nmilcoff.

ViewPresenters registration was aligned and improved on many platforms. You can now obtain the current ViewPresenter from anywhere by resolving the interface IMvxViewPresenter. All thanks to the amazing @martijn00!

The brand new MvxNavigationService that was introduced in MvvmCross 5 is now the default. This means ShowViewModel has been finally removed, as well as MvxNavigatingObject. If you aren’t using it yet, it’s time you take a look at the official documentation.

On this release we have added support for checking whether it’s possible or not to navigate to a specific ViewModel. The default implementation will return true if the View for that ViewModel is reachable from the platform ViewContainer.

Also please note that the intermediary helper class MvxNavigationServiceAppStart has been removed as well, because the classic MvxAppStart now uses MvxNavigationService internally.

IoC

Sometimes you’d like to add some instances or types to an IoC Container for a specific purpose and not to the app-wide container. You can use Child Containers for that:

var container = Mvx.Resolve<IMvxIoCProvider>();
var childContainer = container.CreateChildContainer():
childContainer.RegisterType<IFoo, Foo>(); // Is only registered in Child Container scope
childContainer.Create<IFoo>();

You can create as many and as deeply nested Child Containers as you want - each container inherits all dependencies registered on it’s parent container.

Logging

MvxTrace and everything related was removed. The new (and much improved) logging system was already present since MvvmCross 5.4. If you haven’t heard about it, please take a look at the official documentation

Xamarin.Forms

General stability and bugs fixes

We’ve put a lot of effort in to make sure MvvmCross works with Forms as good as with traditional Xamarin apps! A whole bunch of bugs have been fixed (and we’ve added test scenarios in our playground project to make sure we keep it this way!).

MvxFormsApplication

MvvmCross became much more flexible and it doesn’t require your app to use our own MvxFormsApplication class anymore.

ViewCells

MvxViewCell is now usable! We have fixed a bug and apps won’t crash in runtime anymore. It is recommended that you use MvxViewCell in ListViews instead of the default ViewCell.

Support for “native” views

@martijn00 and @nickrandolph fixed several issues regarding the Forms ViewPresenter not being able to display native views. We now provide a much better support for it!

Xamarin.Forms UWP

You are now free to place your custom renderers in a different assembly. All you have to do to make it work is to add your assembly to the Setup.ViewAssemblies collection.

iOS

@thefex has made it possible to easily navigate to child ViewControllers when using more than 5 bottom tabs. Our default ViewPresenter now supports it out of the box!

Android

Current top activity

Starting with v6, there is a new implementation you can use for IMvxAndroidCurrentTopActivity.

This new implentation uses the Android provided interface Application.IActivityLifecycleCallbacks, while the old one fires all changes monitoring each activity.

The default implementation remains the same, unless you make your Application class inherit from MvxAndroidApplication. In that case, the new version will be used:

[Application]
public class MainApplication : MvxAndroidApplication
{
    public MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
    {
    }
}

Kudos to @nmilcoff and @dazinator.

Activities and backstack

MvxAndroidViewsContainer will (finally!) no longer force every activity to run on a new task (ActivityFlags.NewTask won’t be added anymore by default).

Shared element transitions

Because everyone loves animations, we are lucky that @Plac3hold3r did a great job and improved our support for shared element transitions. As it is a very Android specific topic, you might need to read a bit about how it works before getting your hands into it.

Once you are ready to start implementing it, take a look at our official documentation and the Playground sample if you want to see some code.

Nested fragments

Both versions of our provided ViewPresenters (default and AppCompat) now support nested fragments! To be fair we did support this in the past, but we took it from 1 level indentation to N levels. Quite cool, right? Kudos to @Qwin.

Removed layouts

MvxRelativeLayout, MvxFrameLayout and MvxTableLayout were removed as they were memory inefficient (nothing we can do to improve that).

macOS

Our WebBrowser plugin now has support for macOS! All thanks to @tofutim.

UWP

We now cover scenarios where apps are launched from file associations, URIs and many more! At code level this means MvxFormsWindowsSetup now expects a parameter of type IActivatedEventArgs instead of LaunchActivatedEventArgs. Thanks for this @MartinZikmund!

kipters made a great job adding StarterPack content for UWP! But unfortunately NuGet doesn’t like nuspec content anymore. We are actively looking for a way to improve the installation experience.

Tizen

Although the status is not yet PRD Ready, initial support for the platform was already added. We look forward too see what developers will build with MvvmCross & Tizen!

Others

iOS Support

iOS Support has been redesigned. Most pieces are now part of the main lib, while the sidebar support has become now a plugin that you can install on your iOS project.

MvxNotifyTask

MvxNotifyTask now has an optional callback to set an action to be run when an exception happens.

Improved flexibility Setup

MvvmCross has always been easy to extend and customize, but we never stop improving! Starting with 6.0, @nickrandolph has made it much easier to provide your own implementations for IMvxViewModelByNameLookup, IMvxViewModelByNameRegistry and IMvxViewModelTypeFinder.

Commands

MvxAsyncCommand<T> now implements IMvxCommand, same as others. Thanks to @kipters, @softlion and @nickrandolph for making our lives easier!

Framework Unit Testing

@Cheesebaron took the chance and converted all our Unit Tests to XUnit, which works better for some platforms. After that he didn’t stop there and he added a bunch more of tests. Let’s help him and improve our coverage for the next version!

RaiseCanExecuteChanged is now much easier to test, since @jacobduijzer has added some helpers and extension methods to ensure whether CanExecuteChanged has been raised or not. You can read more about this on the official documentation.

Bindings

@Saratsin added a new type of binding: MvxEventNameTargetBinding (and MvxEventNameTargetBinding<TEventArgs>). This new type is a shortcut for adding OneWay bindings to commands, based on specific events. By default it also passes event handler’s EventArgs (or TEventArgs) as a command parameter (but you can disable it!).

WithDictionaryConversion won’t require you to specify values for every key that you want to use. To be more specific, it will now accept a fallback value. All thanks to @Plac3hold3r. If you don’t know what this is, then maybe it’s time for you to read our official documentation.

Change Log

6.0.0 (2018-04-14)

Full Changelog

Fixed bugs:

  • Playground.Droid creates multiple instances of RootViewModel #2782
  • MvvmCross doesn’t work with F# Android app resources #2772
  • Xamarin Forms Images is not shown on Android when using mvvmcross #2770
  • UWP Photo chooser distorts photo on windows phone #2588
  • Fixing issue with CurrentActivity being null in Playground.Droid #2775 (nickrandolph)
  • Find resource type based on Android.Runtime.ResourceDesignerAttribute #2774 (nosami)

Closed issues:

  • Generic UWP views break compiled bindings #2653

Merged pull requests:

6.0.0-beta8 (2018-04-10)

Full Changelog

Fixed bugs:

  • Crash when Close Viewmodel With Result using MasterDetail #2757
  • Adjusting the resolution of the resource assembly #2777 (nickrandolph)
  • Make show and close of iOS views respect Animated #2767 (martijn00)
  • MvxUISliderValueTargetBinding: Add missing return #2750 (nmilcoff)

Closed issues:

  • ViewControllers animation can’t be disabled for VM Navigate() / Close() #2762
  • [iOS] Using VS AppCenter “AppCenter.Start” while MvxApplication.Initialize results in deadlock since MVX 6 beta7 #2745
  • WPF Presenter documentation is out of date #2743
  • NuGet package descriptions are missing from csproj files #2742

Merged pull requests:

6.0.0-beta7 (2018-03-30)

Full Changelog

Fixed bugs:

  • Playground SheetView crashes Android application #2722
  • Android app hangs on SplashScreen #2721
  • MvxViewPagerAdapter and MvxStateViewPagerAdapter ignore the presence of view model instance inside MvxViewPagerFragmentInfo #2718
  • App didn’t show the right view after add SplashScreen on WPF #2684
  • Language files are not loaded in iOS project #2678
  • Sometimes open the app and then it crashes #2599
  • MvvmCross.Forms cannot replace app’s MainPage #2577
  • Status Bar Style jumps back to default after navigation (iOS) #2463
  • MvxAppCompatDialogFragment Attempt to invoke virtual method on a null object reference #2378
  • Fixes #2722 #2730 (tbalcom)
  • Make sure Forms is loaded when not using a splashscreen #2729 (martijn00)
  • Android add MvxViewVodelRequest to fragment forward life cycle events #2728 (Plac3hold3r)
  • Android Dialogs: Fix close & do not keep references to instances #2711 (nmilcoff)
  • Improvements & register fix for Visibility / Messenger / PictureChooser plugins #2704 (nmilcoff)

Closed issues:

  • Add the ability to only use one instance of a given fragment #2694
  • Need an example of custom activity transitions #2659
    • Skipping DigitalWorkReport.Droid.Resource.String.fab_scroll_shrink_grow_autohide_behavior #2645
  • MvvmCross.Forms version out of sync with Xamarin.Forms Tutorial #2620
  • Pin NuGet package dependencies #2581
  • OnCreate is called after first ContentPage #2549
  • Reason why app crashed MvxSetup.InitializePrimary() called from void? #2508
  • Documentation missing for Xamarin.Forms ViewPresenter #2497
  • Feature request: Broader fragment usage #2495
  • [Android] [MvxRecyclerView] MvxTemplateSelector<TItem> missing ItemTemplateId issue #2422

Merged pull requests:

6.0.0-beta6 (2018-03-19)

Full Changelog

Fixed bugs:

  • RegisterAttribute doesn’t always match the new MvvmCross 6 namespace #2688
  • Lack of Initialization from MvxSplashScreenActivity causes App start from external Intent (ie, Uri routing) to fail in Forms app #2624
  • Xamarin.Forms Android - First page cannot reference Application level StaticResources #2622
  • MvxAppStart swallows exceptions #2586

Closed issues:

  • Using MvvmCross 5.6 NavigationService with autofac IoC #2636
  • [Android] Inconsistency with MvxRecyclerView vs. MvxListView & MvxSpinner #2544

Merged pull requests:

5.7.0 (2018-03-14)

Full Changelog

Fixed bugs:

  • [iOS] Text Replacement does not apply change through the binding #2681

Merged pull requests:

6.0.0-beta5 (2018-03-09)

Full Changelog

Fixed bugs:

  • Fix moving items in the MvxRecyclerAdapter #2664 (kjeremy)

Closed issues:

  • Support for netstandard1.4 in version 6.0 #2649
  • ParameterValues doesn’t set in NavigationService #2646
  • get view api #2643
  • MvvmCross.Plugins.Location.Fused.Droid.Plugin does not load #2637
  • Cleanup “Sidebar” plugin #2626
  • StarterPack does not generate files on vs17 #2595
  • MvxFormsApplication Start, Sleep and Resume gets not called on iOS #2512
  • View shown before ViewModel initialization complete #2478

Merged pull requests:

6.0.0-beta4 (2018-03-02)

Full Changelog

Fixed bugs:

Closed issues:

  • MvvmCross.Plugin.Location.Fused 5.6.3 not compatible with MvvmCross.Droid.Support.v7.AppCompat 5.6.3 #2633
  • MvvmCross.Plugin.Location.Fused 5.6.3 is not compatible with netstandard2.0 #2607

Merged pull requests:

6.0.0-beta3 (2018-02-14)

Full Changelog

Fixed bugs:

  • PluginLoaders not found for platform specific plugins #2611
  • Child View Presentation does not work when using More Tabs (more than five tabs) [iOS] #2609
  • MvxObservableCollection reports wrong index when doing AddRange #2515
  • MvxWindowsPage cannot navigate to MvxContentPage #2466
  • Fixed issue #2515 where MvxObservableCollection.AddRange() reports wrong index #2614 (Strifex)

Merged pull requests:

6.0.0-beta2 (2018-02-12)

Full Changelog

6.0.0-beta1 (2018-02-12)

Full Changelog

Fixed bugs:

  • Fragment close does not work if fragment presentation attribute has backstack set to false #2600
  • Platform.Mac startup exception Foundation.You_Should_Not_Call_base_In_This_Method #2591
  • Custom Presentation Hint Handler is ignored #2589
  • UITextview binding - missing source event info in MvxWeakEventSubscription Parameter name: sourceEventInfo #2543
  • MvxBottomSheetDialogFragment OnDestroy does not consider finsished parameter #2525
  • RegisterNavigationServiceAppStart vs RegisterAppStart #2447
  • MvxExpandableListView GroupClick binding replaces group expanding functionality #2408
  • ‘System.TypeInitializationException’ In ‘MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider’ On UWP Projects #2333
  • Inconsistent PCL profile for PictureChooser #2295
  • #2600 no backstack fragment close does not work hotfix #2601 (thefex)
  • Fix that change presentation add handler is ignored in forms #2592 (martijn00)
  • Fix inheritance for MvxBaseSplitViewController class with constraint #2564 (nmilcoff)
  • Fixing Android attributes #2529 (nickrandolph)
  • MvxBottomSheetDialogFragment: Fix OnDestroy #2526 (nmilcoff)
  • Improve implementation of IMvxAndroidCurrentTopActivity #2513 (nmilcoff)
  • Make Mvx…Cell inherit from IMvxCell instead of IMvxElement #2511 (mubold)
  • Fix MvxTabBarViewController.CloseTab: Pick correct ViewController #2506 (nmilcoff)
  • Switch parameters in MvxException so that first exception is InnerException #2504 (mubold)
  • MvxNavigationServiceAppStart: Don’t swallow exceptions #2471 (nmilcoff)

Closed issues:

  • Navigation service: ChangePresentation should be async #2602
  • [Question] - thoughts on routing for navigation #2563
  • Remove usage of MvxTrace from code #2541
  • Switch NUnit tests to XUnit #2540
  • System.Reflection GetCustomAttributes #2535
  • Inconsistency between MvxCommand<T> and MvxAsyncCommand<T> implementing IMvxCommand #2520
  • Remove IMvxIosModalHost #2475
  • WithConversion<…> does not appear do the same as WithConversion(new …) #2449
  • The new logger infrastructure should not send null messages to IMvxLog #2437
  • [Android] MvxSplashScreenActivity should not have to be the first Activity #2261
  • MvxViewModel<TParameter>.Init should be removed #2257

Merged pull requests: