Launching a Window from the Main Menu

Follow these steps to launch a custom window from the main menu.

  1. To add a new menu item to the main application window's menu in Visual Studio, open MainWindow.xaml in the design surface, then select the menu pad to which you want to add the menu item. Go to the Properties window and select the Items property. This launches the Collection Editor dialog:

  2. Click the Add button to add a new menu item to the menu pad. In the Header property, specify the text you want to appear in the menu item at run time. In the Name property, give the menu item a descriptive name. Our convention is to use the name of the menu pad as the prefix, the text of the menu item as the next portion of the name, and the word "item" as a suffix. For example: ActivitiesCustomerOrdersBar (where Activities is the name of the menu pad and CustomerOrdersBar is the text of the menu item). Click OK to close the dialog.

  3. Go to the Properties Window and select the Events button (the lightning bolt). This displays all the events associated with the menu item. Find the Click event and double-click in the ComboBox to the right of it.

    This creates a new ActivitiesCustomerOrdersBar_Click() event handler method.

  4. Add code to the handler method that instantiates and displays your window. For example, this code instantiates a form and makes it a child of the parent window (MDI-like, but not exactly MDI):

    In C#:

    private void ActivitiesCustomerOrdersBar_Click(object sender, RoutedEventArgs e)
    {
    	mmAppWPF.WindowManager.Show(new CustomerOrdersWindow(), this);
    }

    In VB .NET:

    Private Sub ActivitiesCustomerOrdersBar_Click(sender As Object, e As RoutedEventArgs)
       mmAppWPF.WindowManager.Show(New CustomerOrdersWindow(), Me)
    End Sub

    And this code instantiates a window that is not MDI-like.

    In C#:

    private void ActivitiesCustomerOrdersBar_Click(object sender, RoutedEventArgs e)
    {
    	mmAppWPF.WindowManager.Show(new CustomerOrdersWindow());
    }

    In VB .NET:

    Private Sub ActivitiesCustomerOrdersBar_Click(sender As Object, e As RoutedEventArgs)
       mmAppWPF.WindowManager.Show(New CustomerOrdersWindow())
    End Sub

    And this code instantiates a modal dialog:

    In C#:

    private void ActivitiesCustomerOrdersBar_Click(object sender, RoutedEventArgs e)
    {
    	mmAppWPF.WindowManager.ShowDialog(new CustomerOrdersWindow());
    }

    In VB .NET:

    Private Sub ActivitiesCustomerOrdersBar_Click(sender As Object, e As RoutedEventArgs)
       mmAppWPF.WindowManager.ShowDialog(New CustomerOrdersWindow())
    End Sub



Note: Using the MM .NET Form Manager's Show and ShowDialog methods allow your forms to be displayed properly whether or not your application is localized. For details, see the MM .NET topic Showing Localized Windows Forms


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 05/22/17
Comment or report problem with topic