Jump to: navigation, search

Changes


XAML Tips

377 bytes added, 8 May
/* Device and Platform Responsiveness */
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"><source lang = "XML">''<OnPlatform Android="..." iOS="..." /></source></tab><tab name="OnIdiom"><source lang = "XML">'' or ''<OnIdiom Phone="..." Desktop="..." /></source></tab></tabs>''.
Instead, we should either use the '''multi-tag syntax''' or the '''inline syntax''' for OnPlatform / OnIdiom.
</tabs>
If OnPlatform Values contain multiple subtags (e.g. if x:TypeArguments="View") , the following syntax can be used:
<source lang = "XML">
<ControlTemplate x:Key="ExampleControlTemplate"> <Grid> <OnPlatform x:TypeArguments="View"> <On Platform="Android"> <Button ... Text="Button A" /> ... </On> <On Platform="iOS"> <Grid Button ... Text="Button B" /> ... </On> <On Platform="AndroidWinUI"> <Grid > <Button ... Text="Button C" /> <Label Text="Example" /> ... </Grid> </On> </OnPlatform> </Grid></ControlTemplate>
</source>
364
edits