Platform-Specifics

Platform-specifics allow you to consume functionality that's only available on a specific platform, without implementing custom renderers or effects.

The following platform-specific functionality is built into Xamarin.Forms:

iOS Android Windows
VisualElement.BlurEffect Application.WindowSoftInputModeAdjust Page.ToolbarPlacement
NavigationPage.PrefersLargeTitles ListView.IsFastScrollEnabled MasterDetailPage.CollapsedPaneWidth and MasterDetailPage.CollapseStyle
Page.UseSafeArea TabbedPage.IsSwipePagingEnabled
NavigationPage.IsNavigationBarTranslucent Elevation.Elevation
NavigationPage.StatusBarTextColorMode Application.SendDisappearingEventOnPause, Application.SendAppearingEventOnResume, and Application.ShouldPreserveKeyboardOnResume
Entry.AdjustsFontSizeToFitWidth
Picker.UpdateMode
Page.PrefersStatusBarHidden and Page.PreferredStatusBarUpdateAnimation
ScrollView.ShouldDelayContentTouches

The process for consuming a platform-specific through XAML, or through a fluent code API is as follows:

  1. Add a xmlns declaration or using directive for the Xamarin.Forms.PlatformConfiguration namespace.
  2. Add a xmlns declaration or using directive for the namespace that contains the platform-specific functionality:
    1. On iOS, this is the Xamarin.Forms.PlatformConfiguration.iOSSpecific namespace.
    2. On Android, this is the Xamarin.Forms.PlatformConfiguration.AndroidSpecific namespace. For Android AppCompat, this is the Xamarin.Forms.PlatformConfiguration.AndroidSpecific.AppCompat namespace.
    3. On the Universal Windows Platform, this is the Xamarin.Forms.PlatformConfiguration.WindowsSpecific namespace.
  3. Apply the platform-specific from XAML, or from code with the On<T> fluent API. The value of T can be the iOS, Android, or Windows types from the Xamarin.Forms.PlatformConfiguration namespace.

Note

Note that attempting to consume a platform-specific on a platform where it is unavailable will not result in an error. Instead, the code will execute without the platform-specific being applied.

Platform-specifics consumed through the On<T> fluent code API return IPlatformElementConfiguration objects. This allows multiple platform-specifics to be invoked on the same object with method cascading.

For more information about platform-specifics, see Consuming Platform-Specifics and Creating Platform-Specifics.