This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OnPlatform( | |
(Device.iOS, () => CustomiOSAction()), | |
(Device.Android, () => CustomAndroidAction()) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void OnPlatform(params (string, Action)[] platformActions) => | |
platformActions.ToList().ForEach(pa => { | |
if (pa.Item1 == Device.RuntimePlatform) | |
pa.Item2(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double width2 = OnPlatform(200.0, (Device.iOS, 200), (Device.Android, 150), (Device.UWP, 120)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static T OnPlatform<T>(T defValue, params (string, T)[] platformValues) { | |
foreach (var pv in platformValues) { | |
if (pv.Item1 == Device.RuntimePlatform) | |
return pv.Item2; | |
} | |
return defValue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double width; | |
switch (Device.RuntimePlatform) { | |
case Device.iOS: | |
case Device.Android: | |
width = 200; | |
break; | |
case Device.UWP: | |
width = 120; | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Button Text="Ok"> | |
<Button.WidthRequest> | |
<OnPlatform x:TypeArguments="x:Double"> | |
<On Platform="iOS,Android">200</On> | |
<On Platform="UWP">120</On> | |
</OnPlatform> | |
</Button.WidthRequest> | |
</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Button Text="OK"> | |
<Button.WidthRequest> | |
<OnPlatform x:TypeArguments="x:Double"> | |
<On Platform="iOS">200</On> | |
<On Platform="Android">150</On> | |
</OnPlatform> | |
</Button.WidthRequest> | |
</Button> |
NewerOlder