NativeMenu binding for "About" on MacOS not working?
See original GitHub issueI’m trying to update the About window in the MacOS version of my application.
Following this post:
https://github.com/AvaloniaUI/Avalonia/issues/3541
The problem is that I can’t work out how to bind the AboutCommand
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="About My App" Command="{Binding AboutCommand}" />
</NativeMenu>
</NativeMenu.Menu>
So this is placed in my App.axaml file and then I’ve added
AboutCommand = MiniCommand.CreateFromTask(async () =>
{
AboutDialogWindow = new AboutDialog();
var mainWindow = (App.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
await AboutDialogWindow.ShowDialog(mainWindow);
});
in the Initialize() of App.axaml.cs but I get
[Binding] Error in binding to ‘Avalonia.Controls.NativeMenuItem’.‘Command’: ‘Null value in expression ‘’.’ (NativeMenuItem #6480969)
I do this and the menu is correctly display “About My App” - but it’s greyed out.
I’ve also tried placing the Native Menu in the MainWindow.axaml file, but that doesn’t override it (the default Avalonia About box appears).
I’m obviously just misunderstanding how to implement this. Any advice would be greatly appreciated.
Issue Analytics
- State:
- Created a year ago
- Comments:22 (10 by maintainers)

Top Related StackOverflow Question
Ok, the issue can now be closed. I’ve finally figured out all the parts that need to be implemented. I’ll include sample code here so that if anyone else is having difficulty they have a reference. I still feel that this is overly complicated to replace the AboutAvalonia native menu item and there should be a simpler way to achieve this in a non MVVM application.
Firstly, create a ViewModelBase class:
Then create an AppViewModel class with your AboutCommand public property
Create your AboutDialog.axaml
and code behind class for the about dialog (the code behind can be much simpler than I have here - this is from the code in the avaloina source)
And finally at the top of App.axaml
and in the code behind App.axaml.cs
I hope this might help someone else trying to implement this simple feature.
I still think a static command would be ok in your case. If not, you need to set somehow your App as the DataContext of your Menu and I don’t really see how this should work.