Page 1 of 1

ContextMenuOpening event is not sent when button is disabled

Posted: 27 Dec 2018, 08:07
by nikobarli
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.

Re: ContextMenuOpening event is not sent when button is disabled

Posted: 28 Dec 2018, 10:22
by sfernandez
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.

Re: ContextMenuOpening event is not sent when button is disabled

Posted: 28 Dec 2018, 10:45
by sfernandez
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>

Re: ContextMenuOpening event is not sent when button is disabled

Posted: 29 Dec 2018, 10:23
by nikobarli
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 !

Re: ContextMenuOpening event is not sent when button is disabled

Posted: 31 Dec 2018, 11:20
by sfernandez
Thanks for the report.