Routed command lost after an ElementFlow control is closed

Dec 8, 2009 at 7:45 PM

My program has a main frame that contains a DockPanel, which in turn contains a menu, a toolbar, and a custom control that uses ElementFlow.

Now, after I replaced the custom control that contains the ElementFlow with another control in the DockPanel:


        private void FileCloseExcuted(object sender, ExecutedRoutedEventArgs e)
            FrameworkElement fwe = new PlainDisplay();
            fwe.Width = Double.NaN;
            fwe.Height = Double.NaN;

            myDockPanel.LastChildFill = true;
            UIElementCollection children = myDockPanel.Children;

            children.RemoveAt(children.Count - 1);
            e.Handled = true;

the menuitems in the main menu no longer receives the routed commands such as FileOpenCanExecute etc.

What did I do wrong?