Reputation: 24592
I have this Xaml
Margin="{OnPlatform Android='20,0,20,0', iOS='20,0,20,30'}"
I am changing the Xaml to C#
Is there any better option now than using something like this:
switch(Device.RuntimePlatform)
Upvotes: 2
Views: 1029
Reputation: 34083
According to the Docs there is not. You will still have to use something like this:
double top;
switch (Device.RuntimePlatform)
{
case Device.iOS:
top = 20;
break;
case Device.Android:
case Device.UWP:
default:
top = 0;
break;
}
layout.Margin = new Thickness(5, top, 5, 0);
There is the C# Markup now that might make the syntax a bit easier? Note that that functionality moved/is moving to the Xamarin Community Toolkit
Upvotes: 1