IsEnabled Is Ignored?

Apr 12, 2011 at 10:13 AM

I want to disable a pop-upmenu, so set the IsEnabled flag to false.

However, my right click/shortcut keys still open it.


It is late, so I might have missed something!




Apr 12, 2011 at 2:08 PM

Hi Paul,

This seems to be working o.k in the demo project(see Demo2.xaml.cs).

As expected the click handler(MenuItem_Clicked) is not being called when clicking on a disabled menu but I might be missing something here as well! 

Can you send me a sample code to better illustrate your issue? That would help a lot.



Apr 12, 2011 at 2:14 PM

Hi Ziad,

No code behind UserControl

Set IsEnabled to false at designtime

RightClick at runtime and it pops up



Apr 12, 2011 at 2:18 PM
Edited Apr 12, 2011 at 2:18 PM


<Grid x:Name="LayoutRoot" Background="White">
            <RowDefinition Height="Auto" />
        <StackPanel Grid.Row="0" Orientation="Horizontal">
        <Button Content="PurgeDb" Height="23" x:Name="button1" Width="75" Click="button1_Click" />
            <my:PopupMenu x:Name="pmMain" 
					AccessKeyModifier1="Control" AccessKeyModifier2="Alt" AccessKey="P"
					OpenOnAccessKeyPressed="True" IsEnabled="False">
             <Grid x:Name="grdPopupMenu">
                <ListBox x:Name="lstPopupMenu" FontSize="13">
                        <CheckBox Content="Show Disconnected" IsChecked="{Binding ShowDisconnected,Mode=TwoWay}"></CheckBox>
                    <my:PopupMenuItem Header="Status/Thresholds..." Command="{Binding SelectStatesCommand}"/>
Apr 12, 2011 at 3:23 PM
Edited Apr 12, 2011 at 3:29 PM

Hi Paul,

Sorry if I completely missed that out but I thought you were talking about the PopupMenuItem control instead.

Well in fact the PopupMenu control inherits its IsEnabled property from the ContentControl and as such does pretty nothing!

So thank you for bringing my attention to such an obvious issue. I tackled it by simply adding those two lines of code at the beginning of the Open method:

if (!this.IsEnabled)

You can find the updated code here.



Apr 12, 2011 at 3:28 PM

Cheers for that.

Many Thanks