dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Shell.MenuItemTemplate Sometime Does Not Work #21963

Open david-maw opened 5 months ago

david-maw commented 5 months ago

Description

In a release buil a Shell.MenuItemTemplate which includes x:DataType="MenuItem" does not work correctly (the binding to the Text property does not seem to work).

For example:

    <Shell.MenuItemTemplate>
        <DataTemplate>
            <ContentView>
                <Label Text="{Binding Text}"
                       x:DataType="MenuItem"
                       />
            </ContentView>
        </DataTemplate>
    </Shell.MenuItemTemplate>

Will produce a blank line in a release build on Windows but correctly show the MenuItem Text property in a debug build.

Steps to Reproduce

  1. Download the repository
  2. Create and run a Debug build, you should see this: image
  3. Repeat with a Release Build and the MenuItem lines will be blank.

Link to public reproduction project repository

https://github.com/david-maw/ShellTemplate.git

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Windows 11

Did you find any workaround?

Delete the x:DataType="MenuItem" and it works in both release and debug builds.

Relevant log output

No response

XamlTest commented 5 months ago

Verified on VS 17.10.0 Preview 4.0(8.0.20). Repro on Windows 11, Android 14.0-API34 with below Project: ShellTemplate.zip

Windows: image

Android: image

PureWeen commented 4 months ago

@XamlTest can you verify if this works in .NET7?

And based on that set if this is a regression or not?