Handling WindowCommands like Close, Minimize, and Maximize?

1 reply. Last post: December 7, 2010 10:36 PM by Glenn Layaar
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Chris SwainMember

I'm using the UXDesktop control bound to an ItemsSource to generate my UXWindow objects.  I need to be able to handle some of the commands fired by the windows such as Close, Minimize and Maximize.  I've tried the following, but it doesn't seem to capture the Close command when I click the close button of the UXWindow object.

    public partial class RootView : ViewBase
    {
        public RootView(RootViewModel viewModel)
            : base(viewModel)
        {
            InitializeComponent();
            CommandBinding windowCloseCommandBinding = new CommandBinding(WindowCommands.Close, HandleWindowClose);
            // Create the CommandBindingCollection to hold the command binding
            CommandBindingCollection bindingCollection = new CommandBindingCollection();
            bindingCollection.Add(windowCloseCommandBinding);

            // Set the binding collection to the layout root
            CommandManager.SetCommandBindings(this, bindingCollection);
        }

        private void HandleWindowClose(object sender, ExecutedRoutedEventArgs e)
        {

        }
    }
How can I capture and handle the commands fired from my UXWindow objects in my UXDesktop?
 

You can run the attached sample project to see that the HandleWindowCommand method is never invoked even though I'm doing the CommandBinding to the WindowCommands.Close and Minimize commands.

All times are GMT -5. The time now is 7:00 PM.
Previous Next