Xamarin表单代码隐藏中是否有新的平台检查方法?

Xamarin表单代码隐藏中是否有新的平台检查方法?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我有这个Xaml Margin="{OnPlatform Android='20,0,20,0', iOS='20,0,20,30'}" 我正在将Xaml更改为C# 现在有没有比使用这样的东西更好的选择: switch(Device.RuntimePlatform) 据报道没有。您仍然需要使用以下内容: switch(Device.RuntimePlatform) 双层顶; 交换机(设备运行时平台) { case Device.iOS: top=20; 打破 case设

我有这个Xaml

Margin="{OnPlatform Android='20,0,20,0', iOS='20,0,20,30'}"
我正在将Xaml更改为C#

现在有没有比使用这样的东西更好的选择:

switch(Device.RuntimePlatform)
据报道没有。您仍然需要使用以下内容:

switch(Device.RuntimePlatform)
双层顶;
交换机(设备运行时平台)
{
case Device.iOS:
top=20;
打破
case设备。Android:
case Device.UWP:
违约:
top=0;
打破
}
布局。边距=新厚度(5,顶部,5,0);
现在有可能使语法更容易一点吗?请注意,该功能已移动/正在移动到