The following quick start guide is intended to get you up and running with the C1Menu control. In this quick start, you'll start in Visual Studio to create a new project and add a menu items, submenus and context menu to your application.
XAML Copy Code <c1:C1Menu HorizontalAlignment="Left" VerticalAlignment="Top" Height="Auto" Width="Auto"/>
You have completed the first step of the Menu for WPF quick start. In this step, you created a project and added a C1Menu control to it. In the next step, you will add top-level menu items to the control.
In the last step, you created a WPF project with a C1Menu control attached to it. In this step, you will add three menu items to the C1Menu control.
XAML Copy Code <c1:C1Menu HorizontalAlignment="Left" VerticalAlignment="Top" Height="Auto" Width="Auto"> <c1:C1MenuItem></c1:C1MenuItem> <c1:C1MenuItem></c1:C1MenuItem> <c1:C1MenuItem></c1:C1MenuItem> </c1:C1Menu>
XAML Copy Code <c1:C1MenuItem Height="Auto" Width="Auto" Header="File"></c1:C1MenuItem>
XAML Copy Code <c1:C1MenuItem Height="Auto" Width="Auto" Header="Edit"></c1:C1MenuItem>
XAML Copy Code <c1:C1MenuItem Height="Auto" Width="Auto" Header="Added Items"></c1:C1MenuItem>
In this step, you added top-level menu items to the C1Menu control. In the next step, you will use XAML to add submenus to two of those items.
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.
XAML Copy Code <c1:C1MenuItem Height="Auto" Width="Auto" Header="File"></c1:C1MenuItem> <c1:C1MenuItem Height="Auto" Width="Auto" Header="Edit"></c1:C1MenuItem>
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:C1MenuSeparator/> <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:C1MenuSeparator/> <c1:C1MenuItem Height="Auto" Width="Auto" Header="Close"/> <c1:C1MenuItem Height="Auto" Width="Auto" Header="Close Solution"/> <c1:C1MenuSeparator/> <c1:C1MenuItem Height="Auto" Width="Auto" Header="Exit"/>
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.
In the last step, you added submenus to two of the C1Menu control's menu items. In this step, you will add a C1ContextMenu control to the C1Menu control. This context menu will have one item that, when clicked, will add submenu items to the C1Menu control's top-level "Added Items" top-level menu item that you created in Step 2 of 5: Adding Menu Items.
Complete the following steps:
XAML Copy Code <c1:C1Menu.ContextMenu> <ContextMenu> <MenuItem Height="Auto" Width="Auto" Header="Add Item" Click="AddedItems"/> </ContextMenu> </c1:C1Menu.ContextMenu>
XAML Copy Code <c1:C1MenuItem Height="Auto" Width="Auto" Header="Added Items" x:Name="AddedItems"></c1:C1MenuItem>
Visual Basic Copy CodePrivate Sub AddItemClick(ByVal sender As Object, ByVal e As RoutedEventArgs) Dim menuItem As New C1MenuItem() menuItem.Header = "Added Item" AddedItems.Items.Add(menuItem) End Sub
C# Copy Code private void AddItemClick(object sender, RoutedEventArgs e) { C1MenuItem menuItem = new C1MenuItem(); menuItem.Header = "Added Item"; AddedItems.Items.Add(menuItem); }
In this step, you added a ContextMenu to the C1Menu control. In the next step, you will run the project and see the result of the Menu for WPF quick start.
Now that you have created a WPF project with a C1Menu control, the only thing left to do is run the project and observe the results of your work.
Complete the following steps:
The Open submenu closes.
The two checkable items, Recent Document 1 and Recent Document 2, are grouped together to form a list of mutually exclusive checkable items. You can read more about this by visiting the Checkable Menu Items topic.
Congratulations!
You have completed the Menu for WPF quick start.