maui
maui copied to clipboard
Grid layout breaks in build target='Release' when ColumnDefinitions defined via StaticResource
Description
When the ColumnDefinitions of a grid layout is defined as a static ressource the layout breaks on target='Release'
Correct Layout on build target 'Debug'
Broken layout on build Traget 'Release'
Code
<ContentPage.Resources >
<System:String x:Key="GridColDef">*, *, *, *, *, auto</System:String>
</ContentPage.Resources>
<ScrollView>
<Grid ColumnDefinitions="50,200,*" RowDefinitions="{StaticResource GridColDef}">
<Image Grid.Column="0" Source="dotnet_bot.png" HeightRequest="50" Aspect="AspectFit" VerticalOptions="Center"/>
<Label Grid.Column="1" Text="My Label 1" Style="{StaticResource Headline}" VerticalOptions="Center"/>
<Entry Grid.Column="2" Text="My Entry 1" VerticalOptions="Center"/>
<Image Grid.Row="1" Grid.Column="0" Source="dotnet_bot.png" HeightRequest="50" Aspect="AspectFit" VerticalOptions="Center"/>
<Label Grid.Row="1" Grid.Column="1" Text="My Label 2" Style="{StaticResource Headline}" VerticalOptions="Center"/>
<Entry Grid.Row="1" Grid.Column="2" Text="My Entry 2" />
<Image Grid.Row="2" Grid.Column="0" Source="dotnet_bot.png" HeightRequest="50" Aspect="AspectFit" VerticalOptions="Center"/>
<Label Grid.Row="2" Grid.Column="1" Text="My Label 3" Style="{StaticResource Headline}" VerticalOptions="Center"/>
<Entry Grid.Row="2" Grid.Column="2" Text="My Entry 3" VerticalOptions="Center"/>
<Image Grid.Row="3" Grid.Column="0" Source="dotnet_bot.png" HeightRequest="50" Aspect="AspectFit" VerticalOptions="Center"/>
<Label Grid.Row="3" Grid.Column="1" Text="My Label 4" Style="{StaticResource Headline}" VerticalOptions="Center"/>
<Entry Grid.Row="3" Grid.Column="2" Text="My Entry 4" VerticalOptions="Center"/>
<Image Grid.Row="4" Grid.Column="0" Source="dotnet_bot.png" HeightRequest="50" Aspect="AspectFit" VerticalOptions="Center"/>
<Label Grid.Row="4" Grid.Column="1" Text="My Label 5" Style="{StaticResource Headline}" VerticalOptions="Center"/>
<Entry Grid.Row="4" Grid.Column="2" Text="My Entry 5" VerticalOptions="Center"/>
<Button Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3" x:Name="CounterBtn" Text="Click me" WidthRequest="150" HorizontalOptions="Fill" />
</Grid>
</ScrollView>
Steps to Reproduce
- Create a .net Maui Project
- Replace content in MainPage with sample above
- Build app in target Release
- Start App -> Layout is broken
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
No response
Did you find any workaround?
Never define ColumnDefinitions via StaticResource
Relevant log output
No response
Sample project is here https://github.com/MattHoppler/GridLayoutColDefStatic/tree/62184bf8c191852d4301e641805ad86cbef597dd
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
confirmed. there's an issue with XamlC
one fix would be to have the resource of type RowDefinitionsCollection (with x:Shared="false")