In the last step, you created a Universal Windows application. In this step, you will add a C1Menu control.
Markup |
Copy Code
|
---|---|
<C1:C1DockPanel Grid.Row="1" LastChildFill="False"></C1:C1DockPanel> |
You’ll add the C1Menu within this control.
Markup |
Copy Code
|
---|---|
<TextBlock x:Name="txt" Foreground="Red" Text="" FontSize="16" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="10" /> |
The name of any menu item you select will be displayed in the TextBlock at run time.
Markup |
Copy Code
|
---|---|
<C1:C1Menu x:Name="VisualStudioMenu" C1:C1DockPanel.Dock="Top" DetectBoundaries="True" MinWidth="200" ItemClick="Menu_ItemClick"> <C1:C1Menu.ItemContainerTransitions> <TransitionCollection> <EntranceThemeTransition/> </TransitionCollection> </C1:C1Menu.ItemContainerTransitions> </C1:C1Menu> |
This adds a C1Menu control.
</c1:C1Menu>
tag:
Markup |
Copy Code
|
---|---|
<C1:C1MenuItem Header="File"> <C1:C1MenuItem Header="New"> <C1:C1MenuItem Header="Project..." IsCheckable="True" IsChecked="True" > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Web Site..." > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Team Project..." > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="File..." > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> </C1:C1MenuItem> <C1:C1MenuItem Header="Open"> <C1:C1MenuItem Header="Project..." > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Web Site..." > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="File..." > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> </C1:C1MenuItem> <C1:C1Separator /> <C1:C1MenuItem Header="Close" /> <C1:C1MenuItem Header="Close Solution"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1Separator /> <C1:C1MenuItem Header="Save" > <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Save All" /> <C1:C1Separator /> <C1:C1MenuItem Header="Page Setup"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Print"> <C1:C1MenuItem.Icon> <TextBlock Text="⎙" Style="{StaticResource TextIconStyle}" FontWeight="ExtraBold" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1Separator /> <C1:C1MenuItem Header="Exit"/> </C1:C1MenuItem> <C1:C1MenuItem Header="Edit"> <C1:C1MenuItem Header="Undo"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Redo"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1Separator /> <C1:C1MenuItem Header="Cut"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Copy"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Paste"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> <C1:C1MenuItem Header="Delete" Width="100"> <C1:C1MenuItem.Icon> <TextBlock Text="" Style="{StaticResource TextIconStyle}" /> </C1:C1MenuItem.Icon> </C1:C1MenuItem> </C1:C1MenuItem> <C1:C1MenuItem Header="Window"> <C1:C1MenuItem Header="Document 1" IsCheckable="True" IsChecked="True" /> <C1:C1MenuItem Header="Document 2" IsCheckable="True" IsChecked="True" /> <C1:C1MenuItem Header="Document 3" IsCheckable="True" /> <C1:C1MenuItem Header="Document 4" IsCheckable="True" /> <C1:C1Separator /> <C1:C1MenuItem Header="Exclusive 1" GroupName="Exclusives" IsCheckable="True" IsChecked="True" /> <C1:C1MenuItem Header="Exclusive 2" GroupName="Exclusives" IsCheckable="True" IsChecked="True" /> <C1:C1MenuItem Header="Exclusive 3" GroupName="Exclusives" IsCheckable="True" /> </C1:C1MenuItem> <C1:C1MenuItem Header="Deep"> <C1:C1MenuItem Header="Deep1"> <C1:C1MenuItem Header="Deep2"> <C1:C1MenuItem Header="Deep3"> <C1:C1MenuItem Header="Deep4"> <C1:C1MenuItem Header="Deep5"> </C1:C1MenuItem> </C1:C1MenuItem> </C1:C1MenuItem> </C1:C1MenuItem> </C1:C1MenuItem> </C1:C1MenuItem> |
The above markup adds markup for menu structure.
Visual Basic |
Copy Code
|
---|---|
Private Sub Menu_ItemClick(sender As Object, e As C1.Xaml.SourcedEventArgs) txt.Text = "Item Clicked: " & DirectCast(e.Source, C1.Xaml.C1MenuItem).Header.ToString() End Sub |
C# |
Copy Code
|
---|---|
private void Menu_ItemClick(object sender, C1.Xaml.SourcedEventArgs e) { txt.Text = "Item Clicked: " + ((C1.Xaml.C1MenuItem)e.Source).Header.ToString(); } |
In this step, you added a C1Menu control. In the next step, you will add a C1ContextMenu control to the application.