Shell MenuItemTemplate Broken
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
- Download the repo
- Build and run the main branch (built with RC2 but there was no dropdown for that below, so I used RC1), you'll see:
- What you should see is:
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
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.
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.
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.
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
Yep, that improvement to my workaround did the trick, thanks @Foda , this is now a low priority problem for me.
I have encountered the same situation. Will it be planned to fix this problem?