Basic Library for WPF and Silverlight | ComponentOne
WPF and Silverlight Edition Basic Library / Menu and ContextMenu / Menu and ContextMenu Quick Start / Step 3 of 5: Adding Submenus to Menu Items
In This Topic
    Step 3 of 5: Adding Submenus to Menu Items
    In This Topic

    In the last step, you added the top-level menu items. In this step, you will add submenus to two of the menu items using XAML.

    1. Switch to XAML view.
    2. Select the first two <c1:C1MenuItem> tags. For reference, they should resemble the following:
    XAML
    Copy Code
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="File"></c1:C1MenuItem>
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Edit"></c1:C1MenuItem>
    
    1. To add a submenu to the "File" menu item, add the following markup between the <c1:C1MenuItem Header="File"> and </c1:C1MenuItem> tags:
    XAML
    Copy Code
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="New">
          <c1:C1MenuItem Height="Auto" Width="Auto" Header="Document"/>
          <c1:C1MenuItem Height="Auto" Width="Auto" Header="Project"/>
    </c1:C1MenuItem>
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Open">
          <c1:C1MenuItem Height="Auto" Width="Auto" Header="Document"/>
          <c1:C1MenuItem Height="Auto" Width="Auto" Header="Project"/>
          <c1:C1Separator/>
          <c1:C1MenuItem Header="Recent Document 1" Height="Auto" Width="Auto" 
                         GroupName="CheckedDocuments" IsCheckable="True" IsChecked="True">
          </c1:C1MenuItem>
          <c1:C1MenuItem Header="Recent Document 2" Height="Auto" 
                         Width="Auto" GroupName="CheckedDocuments" IsCheckable="True"> 
          </c1:C1MenuItem>
    </c1:C1MenuItem>
    <c1:C1Separator/>
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Close"/>
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Close Solution"/>
    <c1:C1Separator/>
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Exit"/>
    
    1. To add a submenu to the "Edit" menu item, following markup between the <c1:C1MenuItem Header="Edit"> and </c1:C1MenuItem> tags:
    XAML
    Copy Code
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Undo"/>
    <c1:C1MenuItem Height="Auto" Width="Auto" Header="Redo"/>
    

    In this step, you added submenus to two of the C1Menu control's menu items. In the next step, you will add a C1ContextMenu control to the C1Menu control.