Skip to content

Commit

Permalink
Example code for ContextMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Nov 1, 2024
1 parent 7d23120 commit 44f0383
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
mc:Ignorable="d">

<ikw:SimpleStackPanel>
<local:ControlExample HeaderText="A ContextMenu with checkable MenuItems and Separator.">
<local:ControlExample x:Name="Example1" HeaderText="A ContextMenu with checkable MenuItems and Separator.">
<Button Content="Options">
<Button.ContextMenu>
<ContextMenu>
Expand All @@ -30,7 +30,7 @@
</Button>
</local:ControlExample>

<local:ControlExample HeaderText="A ContextMenu with cascading menus.">
<local:ControlExample x:Name="Example2" HeaderText="A ContextMenu with cascading menus.">
<Button Content="File Options">
<Button.ContextMenu>
<ContextMenu>
Expand All @@ -49,7 +49,7 @@
</Button>
</local:ControlExample>

<local:ControlExample HeaderText="A ContextMenu with icons.">
<local:ControlExample x:Name="Example3" HeaderText="A ContextMenu with icons.">
<Button Content="Edit Options">
<Button.ContextMenu>
<ContextMenu>
Expand All @@ -76,7 +76,7 @@
</Button>
</local:ControlExample>

<local:ControlExample HeaderText="A ContextMenu with icons and InputGestureTexts.">
<local:ControlExample x:Name="Example4" HeaderText="A ContextMenu with icons and InputGestureTexts.">
<Button Content="Edit Options">
<Button.ContextMenu>
<ContextMenu>
Expand All @@ -103,7 +103,7 @@
</Button>
</local:ControlExample>

<local:ControlExample HeaderText="A context MenuFlyout with icons and InputGestureTexts.">
<local:ControlExample x:Name="Example5" HeaderText="A context MenuFlyout with icons and InputGestureTexts.">
<Button Content="Edit Options">
<ui:ContextFlyoutService.ContextFlyout>
<ui:MenuFlyout>
Expand All @@ -130,7 +130,7 @@
</Button>
</local:ControlExample>

<local:ControlExample HeaderText="Text control ContextMenu.">
<local:ControlExample x:Name="Example6" HeaderText="Text control ContextMenu.">
<TextBox MinWidth="150" Text="Some text" />
</local:ControlExample>
</ikw:SimpleStackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,144 @@ public partial class ContextMenuPage
public ContextMenuPage()
{
InitializeComponent();
UpdateExampleCode();
}

#region Example Code

public void UpdateExampleCode()
{

Example1.Xaml = Example1Xaml;
Example2.Xaml = Example2Xaml;
Example3.Xaml = Example3Xaml;
Example4.Xaml = Example4Xaml;
Example5.Xaml = Example5Xaml;
Example6.Xaml = Example6Xaml;
}

public string Example1Xaml => $@"
<Button Content=""Options"">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header=""Reset"" />
<Separator />
<MenuItem
Header=""Repeat""
IsCheckable=""True""
IsChecked=""True"" />
<MenuItem
Header=""Shuffle""
IsCheckable=""True""
IsChecked=""True"" />
</ContextMenu>
</Button.ContextMenu>
</Button>
";

public string Example2Xaml => $@"
<Button Content=""File Options"">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header=""Open"" />
<MenuItem Header=""Send to"">
<MenuItem Header=""Bluetooth"" />
<MenuItem Header=""Desktop (shortcut)"" />
<MenuItem Header=""Compressed file"">
<MenuItem Header=""Compress and email"" />
<MenuItem Header=""Compress to .7z"" />
<MenuItem Header=""Compress to .zip"" />
</MenuItem>
</MenuItem>
</ContextMenu>
</Button.ContextMenu>
</Button>
";

public string Example3Xaml => $@"
<Button Content=""Edit Options"">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header=""Share"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE72D;"" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=""Copy"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE16F;"" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=""Delete"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE107;"" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header=""Rename"" />
<MenuItem Header=""Select"" />
</ContextMenu>
</Button.ContextMenu>
</Button>
";

public string Example4Xaml => $@"
<Button Content=""Edit Options"">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header=""Share"" InputGestureText=""Ctrl+S"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE72D;"" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=""Copy"" InputGestureText=""Ctrl+C"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE16F;"" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=""Delete"" InputGestureText=""Delete"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE107;"" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header=""Rename"" />
<MenuItem Header=""Select"" />
</ContextMenu>
</Button.ContextMenu>
</Button>
";

public string Example5Xaml => $@"
<Button Content=""Edit Options"">
<ui:ContextFlyoutService.ContextFlyout>
<ui:MenuFlyout>
<MenuItem Header=""Share"" InputGestureText=""Ctrl+S"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE72D;"" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=""Copy"" InputGestureText=""Ctrl+C"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE16F;"" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=""Delete"" InputGestureText=""Delete"">
<MenuItem.Icon>
<ui:FontIcon Glyph=""&#xE107;"" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header=""Rename"" />
<MenuItem Header=""Select"" />
</ui:MenuFlyout>
</ui:ContextFlyoutService.ContextFlyout>
</Button>
";

public string Example6Xaml => $@"
<TextBox MinWidth=""150"" Text=""Some text"" />
";

#endregion

}
Expand Down

0 comments on commit 44f0383

Please sign in to comment.