nikobarli
Topic Author
Posts: 152
Joined: 26 Apr 2017, 06:23

ContextMenuOpening event is not sent when button is disabled

27 Dec 2018, 08:07

Hi,

In WPF, we get ContextMenuOpening event on both the button and the grid.
However, in NoesisGUI, the event is not fired (it is fired if the button IsEnabled="True").
<Grid ContextMenuOpening="Grid_ContextMenuOpening">
	<Button Name="testDisabledButton" IsEnabled="False" Content="Disabled Button" ContextMenuOpening="testDisabledButton_ContextMenuOpening">
		<Button.ContextMenu>
			<ContextMenu>
				<MenuItem Header="Test 1"/>
				<MenuItem Header="Test 2"/>
			</ContextMenu>
		</Button.ContextMenu>
	</Button>
</Grid>
What we are trying to do is to find a trigger for displaying ContextMenu on the disabled button. Do you know any good workaround ?

Thanks.

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1524
Joined: 22 Dec 2011, 19:20

Re: ContextMenuOpening event is not sent when button is disabled

28 Dec 2018, 10:22

Hi, it is a bug in our code that ignores disabled elements when raising ContextMenuOpening.
Could you please report it in our bugtracker and we will fix it as soon as possible?
Unfortunately I can't think of a valid way to workaround it.
 
User avatar
sfernandez
Site Admin
Posts: 1524
Joined: 22 Dec 2011, 19:20

Re: ContextMenuOpening event is not sent when button is disabled

28 Dec 2018, 10:45

Just want to make notice that as soon as we fix this bug you will be able to use ContextMenuService.ShowOnDisabled attached property if you want to show the context menu on your disabled button, you won't need to register a handler on the ContextMenuOpening event (unless you want to do other things).
<Button Name="testDisabledButton" IsEnabled="False" Content="Disabled Button" ContextMenuService.ShowOnDisabled="True">
    <Button.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Test 1"/>
            <MenuItem Header="Test 2"/>
        </ContextMenu>
    </Button.ContextMenu>
</Button>
 
nikobarli
Topic Author
Posts: 152
Joined: 26 Apr 2017, 06:23

Re: ContextMenuOpening event is not sent when button is disabled

29 Dec 2018, 10:23

Ok, thanks.

I filed the issue here: https://www.noesisengine.com/bugs/view.php?id=1382
Just want to make notice that as soon as we fix this bug you will be able to use ContextMenuService.ShowOnDisabled attached property if you want to show the context menu on your disabled button, you won't need to register a handler on the ContextMenuOpening event (unless you want to do other things).
Ok, that sounds great !
 
User avatar
sfernandez
Site Admin
Posts: 1524
Joined: 22 Dec 2011, 19:20

Re: ContextMenuOpening event is not sent when button is disabled

31 Dec 2018, 11:20

Thanks for the report.

Who is online

Users browsing this forum: No registered users and 1 guest