-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Binding commands for submenu items makes whole submenu grayed out #3100
Comments
It sounds to me like |
BTW can this be related to CommandProperty becoming direct property recently? It was StyledProperty not too long ago. public static readonly DirectProperty<MenuItem, ICommand> CommandProperty =
Button.CommandProperty.AddOwner<MenuItem>(
menuItem => menuItem.Command,
(menuItem, command) => menuItem.Command = command,
enableDataValidation: true); |
Question: Is this issue solved? Running Avalonia 0.9.11. MenuItem is grayed out and command is not working on a ContextMenu.
Have the same code on a normal Menu and it works just fine. kindest |
@chhadidg issue is not closed, so it probably is not solved. |
Thanks. Is there any other way to execute a command from a contextmenu menuitem? Just started with Avalonia. |
Hi, any news on this topic ? |
I have the same issue with the latest stable version and the following context menu. I cannot get it to work, is there a known workaround?
Testing with 0.10.0-rc1 is not possible at the moment because it crashes with a StackOverflowException which i could not fix |
I created a small test application using the latest |
For now, I am using this solution (hereby an example from my menu with the option to switch between languages):
notes:
|
@Kermel @x2bool It can be fixed with more specific Selector, that will not match parent item, but only its children. In my example "SubItems" class will filter items: <MenuItem Header="Languages" Items="{Binding LanguageMenuItems}" Classes="SubItems">
<MenuItem.Styles>
<Style Selector="MenuItem.SubItems MenuItem">
<Setter Property="Icon" Value="{Binding Icon}"/>
<Setter Property="Header" Value="{Binding LanguageCode}"/>
<Setter Property="Command" Value="{Binding SwitchLanguageCommand}"/>
<Setter Property="CommandParameter" Value="{Binding LanguageCode}"/>
</Style>
</MenuItem.Styles>
</MenuItem> |
@lordzomat I am not sure if you have same issue. But I already see, you have created another one - #5212 |
I am not sure if this issue can be closed as "by design" or can we do something with this to make behavior more clear. |
Is it possible to add @maxkatz6 example to https://avaloniaui.net/docs/controls/menu ? |
Thank you, this helped solving my problem ! |
When SelectCommand is uncommented it makes whole "Commands" submenu disabled. Doesn't matter what value the SelectCommand has, even simple stub or null value grays out the submenu.
0.8.999 - binding disables the submenu
0.8 - binding works as expected and does not result in disabled menu
The text was updated successfully, but these errors were encountered: