exception upon use of OnPlatform WinUI
See original GitHub issueDescription
MAUI app crash when using OnPlatform WinUI. Here is the app xaml to reproduce the error. Please see the comment above the problem xaml code inside a Label tag
<?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SettingsCrash.SettingsPage"> <StackLayout BackgroundColor="Black" WidthRequest="480" VerticalOptions="Center" HorizontalOptions="Center" Padding="20">
<Label Text="Settings"
FontSize="30"
Margin="0,0,0,20"/>
<StackLayout Orientation="Horizontal">
<CheckBox IsChecked="True" />
<Label Text="Function Log" Margin="{OnPlatform WinUI='-90,0,0,0'}" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<CheckBox IsChecked="False" />
<Label Text="Action Log" Margin="{OnPlatform WinUI='-90,0,0,0'}" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Interval Log(Min)" VerticalOptions="Center" InputTransparent="True"/>
<CheckBox IsChecked="True" />
<Label Text="MaxMin Log(Min)" Margin="10,0,10,0" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Pause updates on resize/move" Margin="0,0,20,0" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Vertical" Margin="0,10,0,0">
<Label Text="LogPath" />
<Entry Text="ttt"
IsReadOnly="True"/>
</StackLayout>
<Grid WidthRequest="440"
RowDefinitions="100"
ColumnDefinitions="*,*">
<Button Text="Cancel"
Grid.Column="0"
HeightRequest="50"
WidthRequest="100"
/>
<Button Text="Save"
Grid.Column="1"
HeightRequest="50"
WidthRequest="100"
/> </Grid>
</StackLayout>
</ContentPage>
Steps to Reproduce
- create a new MAUI shell app
- in the AppShell.xaml, paste in this code:
<Shell x:Class="SettingsCrash.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:SettingsCrash" Shell.FlyoutBehavior="Flyout">
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
<ShellContent
Title="Settings"
ContentTemplate="{DataTemplate local:SettingsPage}"
Route="SettingsPage"/>
<ShellContent
Title="Test here" />
</Shell>
-
create another xaml file named SettingsPage.xaml and paste in this code: 4.<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SettingsCrash.SettingsPage"> <StackLayout BackgroundColor="Black" WidthRequest="480" VerticalOptions="Center" HorizontalOptions="Center" Padding="20">
<Label Text="Settings" FontSize="30" Margin="0,0,0,20"/> <StackLayout Orientation="Horizontal"> <CheckBox IsChecked="True" /> <Label Text="Function Log" Margin="{OnPlatform WinUI='-90,0,0,0'}" VerticalOptions="Center" InputTransparent="True"/> </StackLayout> <StackLayout Orientation="Horizontal"> <CheckBox IsChecked="False" />
<Label Text="Action Log" Margin="{OnPlatform WinUI='-90,0,0,0'}" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Interval Log(Min)" VerticalOptions="Center" InputTransparent="True"/>
<CheckBox IsChecked="True" />
<Label Text="MaxMin Log(Min)" Margin="10,0,10,0" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Pause updates on resize/move" Margin="0,0,20,0" VerticalOptions="Center" InputTransparent="True"/>
</StackLayout>
<StackLayout Orientation="Vertical" Margin="0,10,0,0">
<Label Text="LogPath" />
<Entry Text="ttt"
IsReadOnly="True"/>
</StackLayout>
<Grid WidthRequest="440"
RowDefinitions="100"
ColumnDefinitions="*,*">
<Button Text="Cancel"
Grid.Column="0"
HeightRequest="50"
WidthRequest="100"
/>
<Button Text="Save"
Grid.Column="1"
HeightRequest="50"
WidthRequest="100"
/> </Grid>
</StackLayout>
</ContentPage>
build the app, at runtime, select the Settings menu item from the flyout menu.
Version with bug
6.0.400
Last version that worked well
6.0 Release Candidate 3
Affected platforms
Windows, I was not able test on other platforms
Affected platform versions
Windows Build 22000.856
Did you find any workaround?
workaround is to remove the use of Margin=“{OnPlatform}”
Relevant log output
no specific log output
Issue Analytics
- State:
- Created a year ago
- Comments:11 (3 by maintainers)
This issue can only be reproduced in a custom application. The owner of the app is on vacation. Once he is back, we will give you access to the repo
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!