{{UnderConstructionStart}}
<br>
Although '''OnPlatform''' and '''OnIdiom''' have been are used in Xamarin, the following wiki article is valid from MAUI 5.0 (add version flag), as the syntax changed.
'''OnPlatform''' can be used to define different property values based on the platform. Valid Platform names are:
* iOS
* Android
* WinUI (for MAUI Windows)
* further ones see [https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/customize-ui-appearance?view=net-maui-9.0#customize-ui-appearance-with-a-markup-extension-based-on-the-platform here]
<br>
'''OnIdom''' can be used to define different property values based on the device type (e.g. Phone, Tablet, Desktop).
When it comes to the proper syntax, we should stick with the approaches mentioned in the [https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/customize-ui-appearance?view=net-maui-9.0 official documentation].
Means, we should '''avoid ''' using the single-tag syntax like in the example below:
<tabs>
<tab name="OnPlatform">
</tabs>
Instead, we should either use the OnPlatform / OnIdiom '''multi-tag syntax''' (or the '''inline syntax''' for OnPlatform / OnIdiom. ==== Multi-tag syntax ====Here it is mandatory to add '''x:TypeArguments="TheType"''' with the proper type to OnPlatfrom/OnIdiom. ''Default="..."'' only if necessary):is optional.
<tabs>
<tab name="OnPlatform">
</tabs>
or If OnPlatform Values contain multiple subtags (e.g. if x:TypeArguments="View") the following syntax can be used:<source lang = "XML"><OnPlatform x:TypeArguments="..."> <On Platform="iOS"> <Grid ... / OnIdiom > ... </On> <On Platform="Android"> <Grid ... /> ... </On></OnPlatform></source> {{Attention|When using ''GridLength'' as a type in OnPlatform/OnIdiom, it should only be used in combination with the inline syntax''' (with or without .}} ==== Inline syntax ====When using the inline syntax, the type should not be specified. ''Default=''):is optional.
<tabs>
<tab name="OnPlatform">
</tabs>
=== Complex values ===* If the OnPlatform/OnIdiom value contains a '''Binding''', '''StaticResource''' or any other complex value in curly brackets, it is recommended to use the '''inline syntax'''. Although there is no official documentation, it seems to work according to our experience. However, the multi-tag syntax doesn't seem to work always for such cases.* DynamicResource values are not supported in OnIdiom / OnPlatform.* If the value contains any special characters like '''"''' or ''',''' or a '''string''' when using the OnIdiom or OnPlatform inline variant (both OnPlatform and OnIdiom), it needs to be wrapped between '''' '''' . But be careful with using apostrophes - when using them around curly brackets {} it can lead to an error.
<tabs>
<tab name="Don't">
<source lang = "XML">
Margin="{OnIdiom 10,2, Phone=2,0}"
</source>
</tab>
<tab name="Instead do">
<source lang = "XML">
Margin="{OnIdiom '10,2', Phone='2,0'}"
</source>
</tab>
</tabs>
* But be careful with using apostrophes - when using them around curly brackets {} it can lead to an error* If OnIdiom / OnPlatform === Complex values contain multiple tags (e.g. when x:TypeArguments="View"), ==If the OnPlatform/OnIdiom value contains a '''multi-tagBinding''' syntax should be used.* When using , '''GridLengthStaticResource''' as type or any other complex value in OnPlatform/OnIdiomcurly brackets, it should only be used with is recommended to use the '''inline syntax'''.**The GridLengthTypeConverter Although there is not accessible on no official documentation, it seems to work according to our experience. However, the GridLength struct (httpsmulti-tag syntax doesn't seem to work always for such cases. DynamicResource values seem not to be supported in OnIdiom / OnPlatform. <tabs><tab name="Don't"><source lang = "XML"><OnIdiom x:TypeArguments="..." Default="{Binding ...}"> <OnIdiom.Phone>{Binding ...}<//githubOnIdiom.comPhone></dotnetOnIdiom></mauisource></issuestab><tab name="Instead do"><source lang = "XML">Header="{OnIdiom Default={Binding ...}, Phone={Binding ...}}"</source></tab></10894)tabs>
{{Attention|Unreliable Support: When Behavior may vary when using bindings or complex resources, behavior may vary across platforms. Although it seems to work with the inline syntax according to our experiences, it is recommended to test these edge cases thoroughly.}}
{{UnderConstructionEnd}}