Xamarin.Forms experimental flags

When a new Xamarin.Forms feature is implemented, it's sometimes put behind an experimental flag. This enables the engineering team to provide new features to you more quickly, while still being able to change feature APIs before they move to a stable release. The experimental flag is then removed once the feature moves to a stable release.

Xamarin.Forms includes the following experimental flags:

  • AppTheme_Experimental
  • CarouselView_Experimental
  • Expander_Experimental
  • Markup_Experimental
  • MediaElement_Experimental
  • RadioButton_Experimental
  • Shapes_Experimental
  • Shell_UWP_Experimental
  • SwipeView_Experimental

Using functionality that's behind an experimental flag requires you to enable the flag, or flags, in your application. There are two approaches for enabling experimental flags:

  • Enable the experimental flag, or flags, in your platform projects.
  • Enable the experimental flag, or flags, in your App class.

Warning

Consuming functionality that's behind an experimental flag, without enabling the flag, will result in your application throwing an exception that indicates which flag must be enabled.

Enable flags in platform projects

The Xamarin.Forms.Forms.SetFlags method can be used to enable an experimental flag in your platform projects:

Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental");

The SetFlags method should be invoked in your AppDelegate class on iOS, in your MainActivity class on Android, and in your App class on UWP.

Important

Enabling an experimental flag in your platform projects must occur before the Forms.Init method is invoked.

The Xamarin.Forms.Forms.SetFlags method accepts a string array argument, which makes it possible to enable multiple experimental flags in a single method call:

Xamarin.Forms.Forms.SetFlags(new string[] { "CarouselView_Experimental", "MediaElement_Experimental", "SwipeView_Experimental" });

Warning

Never call the SetFlags method more than once, as subsequent calls will overwrite the result of previous calls.

Enable flags in your App class

The Device.SetFlags method can be used to enable an experimental flag in the App class in your shared code project:

Device.SetFlags(new string[]{ "MediaElement_Experimental" });

The Device.SetFlags method accepts an IReadOnlyList<string> argument, which makes it possible to enable multiple experimental flags in a single method call:

Device.SetFlags(new string[]{ "CarouselView_Experimental", "MediaElement_Experimental", "SwipeView_Experimental" });

Warning

Never call the SetFlags method more than once, as subsequent calls will overwrite the result of previous calls.