WinUI | ComponentOne
Controls / Menu / Quick Start
In This Topic
    Quick Start
    In This Topic

    The following quick start guide is intended to get you up and running with the Menu control. In this quick start, you start with creating a new application, adding the Menu control to it and then adding the MenuItems to the Menu control.

    Menu with menu items

    Create a WinUI Application and add References

    1. In Visual Studio, create a new WinUI App. For detailed steps, see Configure WinUI Application.
    2. In the Solution Explorer, right click Dependencies and select Manage NuGet Packages.
    3. In NuGet Package Manager, select nuget.org as the Package source.
    4. Search and select the following package and click Install.
      • C1.WinUI.Menu

    Back to Top

    Configure the Menu control

    1. Declare the namespace using the following code in XAML:
      XAML
      Copy Code
      xmlns:c1 ="using:C1.WinUI.Menu"
      
    2. Place the cursor between the <Grid></Grid> tag and add the following code to create a menu using the C1Menu class, set its orientation and alignment.
      XAML
      Copy Code
      <c1:C1Menu x:Name="WordMenu" Orientation="Horizontal" VerticalAlignment="Top"></c1:C1Menu>
      
    3. Add items to the menu using C1MenuItem class using the following code.
      XAML
      Copy Code
      <c1:C1MenuItem Header="File">
          <c1:C1MenuItem Header="New">
              <c1:C1MenuItem Header="Document"/>
              <c1:C1MenuItem Header="Project"/>
          </c1:C1MenuItem>
          <c1:C1MenuItem Header="Open">
              <c1:C1MenuItem Header="Document"/>
              <c1:C1MenuItem Header="Project"/>
              <c1:C1MenuItem Header="Recent Document 1">
              </c1:C1MenuItem>
              <c1:C1MenuItem Header="Recent Document 2">
              </c1:C1MenuItem>
          </c1:C1MenuItem>
          <c1:C1MenuItem Header="Close Solution"/>
          <c1:C1MenuItem Header="Save"/>
          <c1:C1MenuItem Header="Exit"/>
      </c1:C1MenuItem>
      <c1:C1MenuItem Header="Edit">
          <c1:C1MenuItem Header="Undo"/>
          <c1:C1MenuItem Header="Redo"/>
      </c1:C1MenuItem>
      <c1:C1MenuItem Header="Build"/>
      

    Back to Top

    Build and Run the Project

    1. Click Build | Build Solution to build the project.
    2. Press F5 to run the project.

    Back to Top