Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys

I have a bit problem in menu commands, that trying exit from window with this XAML code:
XML
<Menu>
    <MenuItem Header="_File">
        <MenuItem Header="a" />
        <Separator />
        <MenuItem Header="E_xit" InputGestureText="Alt+F4" Command="ApplicationCommands.Close" />
    </MenuItem>
</Menu>

But when click in File menu, the Exit item is disabled, what problem? May it's not bind to window? How to do this?

Thanks in advacne:)
Posted
Updated 29-Jul-12 9:27am
v2

Have you tried adding your own close method and calling that instead of sending a command ? Have you tried removing the InputGesture ? I don't know the answer, but it seems to me like some trial and error would help work it out.
 
Share this answer
 
Comments
hzawary 30-Jul-12 6:07am    
When I use 'Command="ApplicationCommands.Close"' in 'MenuItem', this option disabled on running menu of window! May you test it?
I used this code in window XAML:
XML
<window.inputbindings>
    <keybinding command="NotACommand" modifiers="Alt" key="F4" />
    <keybinding command="Close" key="F2" />
</window.inputbindings>
<window.commandbindings>
    <commandbinding command="Close" executed="CommandBinding_Executed" />
</window.commandbindings>

And this code in the menu:
XML
<menu>
    <menuitem header="_File">
        <menuitem header="a" />
        <separator />
        <menuitem header="E_xit" inputgesturetext="F2" command="ApplicationCommands.Close" />
    </menuitem>
</menu>

Finally the problem is solved;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900