maui icon indicating copy to clipboard operation
maui copied to clipboard

Shell MenuItemTemplate Broken

Open david-maw opened this issue 1 year ago • 5 comments

Description

I'm not sure exactly how it is broken but the symptom seems to be that MenuItem names vanish in the Shell flyout - whether they are not there or are white on a white background I have not investigated.

Steps to Reproduce

  1. Download the repo
  2. Build and run the main branch (built with RC2 but there was no dropdown for that below, so I used RC1), you'll see:
  3. Image
  4. What you should see is:
  5. Image

Link to public reproduction project repository

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

Version with bug

9.0.0-rc.1.24453.9

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.91 SR9.1

Affected platforms

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

Affected platform versions

Windows 11, Android 14

Did you find any workaround?

Sort of, use x:DataType="BaseShellItem" in both templates, which seems like it should not work for the MenuItemTemplate because BaseShellItem doesn't have a "Text" property and a build does indeed generate a warning to that effect but it works anyway.

Relevant log output

No response

david-maw avatar Oct 11 '24 02:10 david-maw

We've found some similar issues:

  • #21963 , similarity score: 86%
  • #14865 , similarity score: 81%

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

similar-issues-ai[bot] avatar Oct 11 '24 02:10 similar-issues-ai[bot]

I can repro it at Windows platform on the latest 17.12.0 Preview 2.1(9.0.0-rc.1.24453.9), but it works fine on 8.0.91.

jaosnz-rep avatar Oct 11 '24 02:10 jaosnz-rep

Hello! In NET 9 we've made DataType more robust in checking if the specified type matches the assigned BindingContext during the binding step (https://github.com/dotnet/maui/blob/net9.0/src/Controls/src/Core/Binding.cs#L129-L137). In this case, MenuItem isn't actually a ShellItem -- it gets implicitly converted to MenuShellItem which isn't a public class.

For now, just remove the x:DataType on the MenuItem style.

Foda avatar Oct 11 '24 21:10 Foda

Just to add to your workaround, if you use BaseShellItem as the DataType, you can use the Title property. MenuShellItem internally maps Text to Title

Foda avatar Oct 14 '24 17:10 Foda

Yep, that improvement to my workaround did the trick, thanks @Foda , this is now a low priority problem for me.

david-maw avatar Oct 15 '24 15:10 david-maw

I have encountered the same situation. Will it be planned to fix this problem?

yiliyunfan avatar Dec 17 '24 07:12 yiliyunfan