Skip to content

Commit

Permalink
Example code for MenuBar
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Nov 18, 2024
1 parent 50979b5 commit eb8744a
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel>
<local:ControlExample HeaderText="A simple MenuBar" XamlSource="MenuBar\MenuBarSample1.txt">
<local:ControlExample x:Name="Example1" HeaderText="A simple MenuBar">
<StackPanel>
<TextBlock x:Name="SelectedOptionText" Text="" />
<Menu x:Name="Example1">
<Menu x:Name="Menu1">
<MenuItem Header="File">
<MenuItem
x:Name="o1"
Expand Down Expand Up @@ -62,10 +62,10 @@
</StackPanel>
</local:ControlExample>

<local:ControlExample HeaderText="MenuBar with keyboard accelerators" XamlSource="Menubar\MenuBarSample3.txt">
<local:ControlExample x:Name="Example2" HeaderText="MenuBar with keyboard accelerators">
<StackPanel>
<TextBlock x:Name="SelectedOptionText1" Text="" />
<Menu x:Name="Example2">
<Menu x:Name="Menu2">
<MenuItem Header="File">
<MenuItem Header="New" InputGestureText="Ctrl+N" />
<MenuItem Header="Open..." InputGestureText="Ctrl+O" />
Expand All @@ -87,10 +87,10 @@
</StackPanel>
</local:ControlExample>

<local:ControlExample HeaderText="MenuBar with submenus, separators, and radio items" XamlSource="MenuBar\MenuBarSample2.txt">
<local:ControlExample x:Name="Example3" HeaderText="MenuBar with submenus, separators, and radio items">
<StackPanel>
<TextBlock x:Name="SelectedOptionText2" Text="" />
<Menu x:Name="Example3">
<Menu x:Name="Menu3">
<MenuItem Header="File">
<MenuItem Header="New">
<MenuItem
Expand Down Expand Up @@ -186,10 +186,10 @@
</StackPanel>
</local:ControlExample>

<local:ControlExample HeaderText="Ribbon">
<!--<local:ControlExample HeaderText="Ribbon">
<local:ControlExample.Example>
<Ribbon />
</local:ControlExample.Example>
</local:ControlExample>
</local:ControlExample>-->
</StackPanel>
</ui:Page>
172 changes: 171 additions & 1 deletion source/iNKORE.UI.WPF.Modern.Gallery/ControlPages/MenuBarPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class MenuBarPage : Page
public MenuBarPage()
{
InitializeComponent();
UpdateExampleCode();
}

private void OnElementClicked(object sender, RoutedEventArgs e)
Expand All @@ -49,9 +50,178 @@ private void OnElementClicked(object sender, RoutedEventArgs e)

public void UpdateExampleCode()
{

Example1.Xaml = Example1Xaml;
Example2.Xaml = Example2Xaml;
Example3.Xaml = Example3Xaml;
}

public string Example1Xaml => $@"
<Menu x:Name=""Menu1"">
<MenuItem Header=""File"">
<MenuItem
x:Name=""o1""
Click=""OnElementClicked""
Header=""New"" />
<MenuItem
x:Name=""o2""
Click=""OnElementClicked""
Header=""Open"" />
<MenuItem
x:Name=""o3""
Click=""OnElementClicked""
Header=""Save"" />
<MenuItem
x:Name=""o4""
Click=""OnElementClicked""
Header=""Exit"" />
</MenuItem>
<MenuItem Header=""Edit"">
<MenuItem
x:Name=""o5""
Click=""OnElementClicked""
Header=""Undo"" />
<MenuItem
x:Name=""o6""
Click=""OnElementClicked""
Header=""Cut"" />
<MenuItem
x:Name=""o7""
Click=""OnElementClicked""
Header=""Copy"" />
<MenuItem
x:Name=""o8""
Click=""OnElementClicked""
Header=""Paste"" />
</MenuItem>
<MenuItem Header=""Help"">
<MenuItem
x:Name=""o9""
Click=""OnElementClicked""
Header=""About"" />
</MenuItem>
</Menu>
";

public string Example2Xaml => $@"
<Menu x:Name=""Menu2"">
<MenuItem Header=""File"">
<MenuItem Header=""New"" InputGestureText=""Ctrl+N"" />
<MenuItem Header=""Open..."" InputGestureText=""Ctrl+O"" />
<MenuItem Header=""Save"" InputGestureText=""Ctrl+S"" />
<MenuItem Header=""Exit"" InputGestureText=""Ctrl+E"" />
</MenuItem>
<MenuItem Header=""Edit"">
<MenuItem Header=""Undo"" InputGestureText=""Ctrl+Z"" />
<MenuItem Header=""Cut"" InputGestureText=""Ctrl+X"" />
<MenuItem Header=""Copy"" InputGestureText=""Ctrl+C"" />
<MenuItem Header=""Paste"" InputGestureText=""Ctrl+V"" />
</MenuItem>
<MenuItem Header=""Help"">
<MenuItem Header=""About"" InputGestureText=""Ctrl+I"" />
</MenuItem>
</Menu>
";

public string Example3Xaml => $@"
<Menu x:Name=""Menu3"">
<MenuItem Header=""File"">
<MenuItem Header=""New"">
<MenuItem
x:Name=""z1""
Click=""OnElementClicked""
Header=""Plain Header Document"" />
<MenuItem
x:Name=""z2""
Click=""OnElementClicked""
Header=""Rich Header Document"" />
<MenuItem
x:Name=""z3""
Click=""OnElementClicked""
Header=""Other Formats"" />
</MenuItem>
<MenuItem
x:Name=""z4""
Click=""OnElementClicked""
Header=""Open"" />
<MenuItem
x:Name=""z5""
Click=""OnElementClicked""
Header=""Save"" />
<Separator />
<MenuItem
x:Name=""z6""
Click=""OnElementClicked""
Header=""Exit"" />
</MenuItem>
<MenuItem Header=""Edit"">
<MenuItem
x:Name=""z7""
Click=""OnElementClicked""
Header=""Undo"" />
<MenuItem
x:Name=""z8""
Click=""OnElementClicked""
Header=""Cut"" />
<MenuItem
x:Name=""z9""
Click=""OnElementClicked""
Header=""Copy"" />
<MenuItem
x:Name=""z11""
Click=""OnElementClicked""
Header=""Paste"" />
</MenuItem>
<MenuItem Header=""View"">
<MenuItem
x:Name=""z12""
Click=""OnElementClicked""
Header=""Output"" />
<Separator />
<ui:RadioMenuItem
x:Name=""z13""
Click=""OnElementClicked""
GroupName=""OrientationGroup""
Header=""Landscape"" />
<ui:RadioMenuItem
x:Name=""z14""
Click=""OnElementClicked""
GroupName=""OrientationGroup""
Header=""Portrait""
IsChecked=""True"" />
<Separator />
<ui:RadioMenuItem
x:Name=""z15""
Click=""OnElementClicked""
GroupName=""SizeGroup""
Header=""Small icons"" />
<ui:RadioMenuItem
x:Name=""z16""
Click=""OnElementClicked""
GroupName=""SizeGroup""
Header=""Medium icons""
IsChecked=""True"" />
<ui:RadioMenuItem
x:Name=""z17""
Click=""OnElementClicked""
GroupName=""SizeGroup""
Header=""Large icons"" />
</MenuItem>
<MenuItem Header=""Help"">
<MenuItem
x:Name=""z18""
Click=""OnElementClicked""
Header=""About"" />
</MenuItem>
</Menu>
";

#endregion

}
Expand Down

0 comments on commit eb8744a

Please sign in to comment.