Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Default Value for OnPlatform

StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭
edited April 2017 in Xamarin.Forms


The old OnPlatform mechanism used to pick the iOS value as default for a non-specified platform. The new (as of 2.3.4) mechanism doesn't do that and instead returns default(T). This means that when you try to get your code running in a new platform, most of the OnPlatform uses will return an inappropriate value.

The issue is only present in XAML, as the recommended way of doing platform switch in c# is to use a switch statement (

This has been pointed out here:

API Changes


public T OnPlatform<T>.Default { get; set; }

Intended Use Case

<ToolbarItem Clicked="Save_Clicked" >
        <OnPlatform x:TypeArguments="x:String" Default="Save">
            <On Platform = "iOS" Value="Done" />

Accepted · Last Updated


Sign In or Register to comment.