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:C1ContextMenuService.ContextMenu> <c1:C1ContextMenu Width="Auto" Height="Auto"> <c1:C1MenuItem Height="Auto" Width="Auto" Header="Add Item" Click="C1MenuItem_AddOnClick"/> </c1:C1ContextMenu> </c1:C1ContextMenuService.ContextMenu>
XAML Copy Code <c1:C1MenuItem Height="Auto" Width="Auto" Header="Added Items" x:Name="AddedItems"></c1:C1MenuItem>
Visual Basic Copy CodePrivate Sub C1MenuItem_AddOnClick(ByVal sender As Object, ByVal e As C1.Silverlight.SourcedEventArgs) Dim C1MenuItemAdd As New C1.Silverlight.C1MenuItem() C1MenuItemAdd.Header = "Added Item" AddedItems.Items.Add(C1MenuItemAdd) End Sub
C# Copy Code private void C1MenuItem_AddOnClick(object sender, C1.Silverlight.SourcedEventArgs e) { C1.Silverlight.C1MenuItem C1MenuItemAdd = new C1.Silverlight.C1MenuItem(); C1MenuItemAdd.Header = "Added Item"; AddedItems.Items.Add(C1MenuItemAdd); }
In this step, you added a C1ContextMenu control to the C1Menu control. In the next step, you will run the project and see the result of the Menu for Silverlight quick start.