Traitée WPF menu issue

  • lundi 6 août 2012 04:44
     
     

    I Have menu on MainWindow.xaml file

    <MenuItem Header="File">
                        <MenuItem Header="Save Job File" Command="ApplicationCommands.Save"/>
                        <MenuItem Header="Open Job File..." Command="ApplicationCommands.Open"/>
    </MenuItem>

    In App.xaml.cs file I have this:
                CommandManager.RegisterClassCommandBinding(typeof(MainWindow), new CommandBinding(ApplicationCommands.Open, Open, CanOpen));
                CommandManager.RegisterClassCommandBinding(typeof(MainWindow), new CommandBinding(ApplicationCommands.Save, Save, CanSave));

    #region Open

            private void Open(object sender, ExecutedRoutedEventArgs args)
            {
                ServiceLocator.Current.GetInstance<IJobFileService>().OpenJobFile();
            }

            private void CanOpen(object sender, CanExecuteRoutedEventArgs args)
            {
                args.CanExecute = true;
            }

            #endregion

            #region Save

            private void Save(object sender, ExecutedRoutedEventArgs args)
            {
                ServiceLocator.Current.GetInstance<IJobFileService>().SaveJobFile();
            }

            private void CanSave(object sender, CanExecuteRoutedEventArgs args)
            {
                // Can only save a job file when a label editor is selected
                args.CanExecute = true;
            }

            #endregion

    I know that args.CanExcecute returns true for both menu but my menu items are still stays disable when Open a popup control and then try to open menu to save job file. my popup control is already getting closed when I click on menu. See Below

    pls help.

    thanks

Toutes les réponses