Click here to Skip to main content
13,445,901 members (37,219 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi guys

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

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 29-Jul-12 7:23am
Updated 29-Jul-12 9:27am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I used this code in window XAML:
    <keybinding command="NotACommand" modifiers="Alt" key="F4" />
    <keybinding command="Close" key="F2" />
    <commandbinding command="Close" executed="CommandBinding_Executed" />

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

Finally the problem is solved;)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180314.2 | Last Updated 30 Jul 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100