maui icon indicating copy to clipboard operation
maui copied to clipboard

Grid layout breaks in build target='Release' when ColumnDefinitions defined via StaticResource

Open MattHoppler opened this issue 1 year ago • 4 comments

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'

Grid_correct

Broken layout on build Traget 'Release'

Grid_broken

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

  1. Create a .net Maui Project
  2. Replace content in MainPage with sample above
  3. Build app in target Release
  4. 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

MattHoppler avatar Jan 30 '24 12:01 MattHoppler

Sample project is here https://github.com/MattHoppler/GridLayoutColDefStatic/tree/62184bf8c191852d4301e641805ad86cbef597dd

MattHoppler avatar Jan 30 '24 12:01 MattHoppler

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.

ghost avatar Jan 30 '24 19:01 ghost

confirmed. there's an issue with XamlC

StephaneDelcroix avatar Feb 20 '24 12:02 StephaneDelcroix

one fix would be to have the resource of type RowDefinitionsCollection (with x:Shared="false")

StephaneDelcroix avatar Feb 20 '24 15:02 StephaneDelcroix