New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menus redesign #3855
Comments
Thank you! This was the first observation on "out-of-place" feel for Avalonia apps in our feedback testing. |
It's also a good default :) |
For reference, UWP has more flexible contextmenu/menu/appbar c. UIElement.ContextFlyout (equivalent of ContextMenu) is defined as FlyoutBase. Developer can set either MenuFlyout (equivalent of TemplatedMenu but only for context menus) or Flyout (just any Content in context Popup). For application menu developer can use CommandBar with buttons and AppBarButton.Flyout (which could use any FlyoutBase including MenuFlyout) or more typical for win32 world MenuBar. Developer can't use any FlyoutBase with MenuBar, but all MenuFlyoutItemBase classes are available for both MenuBar and MenuFlyout. MenuFlyout (also supports child items in same way as MenuBar): CommandBarFlyout is used as TextBox context menu: CommandBar as an alternative to MenuBar: Notes:
Links: |
A few problems that would need to be addressed with this design:
|
This issue seems to have gone stale so bumping this again. Working on improving the Menu in Ryujinx and I'm running into issues with the inconsistency between Native Menu and Menu. |
MenuFlyout doesn't seems to work with ItemTemplate? <Button Grid.Row="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Content="Add Component">
<Button.Flyout>
<MenuFlyout Items="{Binding AvailableComponents}">
<MenuFlyout.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Content="{Binding Name}"/>
<Button Content="{Binding Name}"/>
<Button Content="{Binding Name}"/>
<TextBlock>asdasd</TextBlock>
</StackPanel>
</DataTemplate>
</MenuFlyout.ItemTemplate>
</MenuFlyout>
</Button.Flyout>
</Button> |
What version are you using? There was a fix in 11.0.0-preview5: #10020. |
Would be great to have some love given to Menus inside TrayIcon as well. I had to scramble for an alternative solution because there's no support for things like changing the items in the menu there from inside the application - there's no public property to tinker with that. |
The old way of always rendering menus manually isn't really cross-platform. Right now we have a way to define the global menu for the window, but the API looks like it was attached with a piece of a duct tape (fortunately, the blue one).
It also doesn't cover context menus that are also expected to match platform's look and feel.
So the proposed change it to make the
NativeMenu
model class to be the primary way of defining menus while still keeping the support for complex custom menu layouts for apps that need those.The new classes would be:
Menu
= oldNativeMenu
- a visual-less list of menu itemsMenuItem
= oldNativeMenuItem
- a visual-less representation of menu item: text, icon, check state, submenuTemplatedMenu
,TemplatedMenuItem
= refactored oldMenu
classes changed to accomodateMenu
andMenuItem
separation.Control.ContextMenu
should accept bothMenu
andTemplatedMenu
and displayMenu
as native menu if platform supports it, or create aTemplatedMenu
to display it as our custom-rendered menuWindow
will now haveWindow.Menu
property which accepts bothMenu
andTemplatedMenu
.WindowMenuBar
control will exportMenu
as the window menu or create aTemplatedMenu
instance and render it instead.The current
Menu
control will be replaced byTemplatedMenuBar
that hasMenu
property which should also accept bothMenu
andTemplatedMenu
classes.That way we do the native menu drawing by default, fall back to our own menu implementations if native menus are unavailable and still keep a way to enforce customized menus while having a unified API.
The text was updated successfully, but these errors were encountered: