|
| 1 | +<Window x:Class="WpfHamburgerMenuApp.MainWindow" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 5 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 6 | + xmlns:local="clr-namespace:WpfHamburgerMenuApp" |
| 7 | + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" |
| 8 | + mc:Ignorable="d" |
| 9 | + Title="WPF Hamburger Menu Sample" |
| 10 | + Height="600" |
| 11 | + Width="1080" |
| 12 | + Foreground="White" |
| 13 | + WindowStartupLocation="Manual"> |
| 14 | + |
| 15 | + <Window.Resources> |
| 16 | + <Storyboard x:Key="OpenMenu"> |
| 17 | + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="GridMenu"> |
| 18 | + <EasingDoubleKeyFrame KeyTime="0" Value="50"/> |
| 19 | + <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="200"/> |
| 20 | + </DoubleAnimationUsingKeyFrames> |
| 21 | + </Storyboard> |
| 22 | + <Storyboard x:Key="CloseMenu"> |
| 23 | + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="GridMenu"> |
| 24 | + <EasingDoubleKeyFrame KeyTime="0" Value="200"/> |
| 25 | + <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="50"/> |
| 26 | + </DoubleAnimationUsingKeyFrames> |
| 27 | + </Storyboard> |
| 28 | + </Window.Resources> |
| 29 | + |
| 30 | + <Window.Triggers> |
| 31 | + <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="ButtonOpenMenu"> |
| 32 | + <BeginStoryboard Storyboard="{StaticResource OpenMenu}"/> |
| 33 | + </EventTrigger> |
| 34 | + <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="ButtonCloseMenu"> |
| 35 | + <BeginStoryboard Storyboard="{StaticResource CloseMenu}"/> |
| 36 | + </EventTrigger> |
| 37 | + </Window.Triggers> |
| 38 | + |
| 39 | + <Grid> |
| 40 | + <Grid x:Name="GridMenu" Width="50" HorizontalAlignment="Left" Background="#FF3A3A3A"> |
| 41 | + <DockPanel> |
| 42 | + <Grid x:Name="SettingsView" DockPanel.Dock="Bottom" HorizontalAlignment="Stretch"> |
| 43 | + <StackPanel Height="100" RenderTransformOrigin="0.3,0.3"> |
| 44 | + <Grid ToolTip="Help" > |
| 45 | + <Button x:Name="ButtonOpenHelp" Margin="0" Height="50" Width="200" Background="{x:Null}" BorderBrush="{x:Null}" HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalAlignment="Center" Click="ButtonOpenHelp_Click" > |
| 46 | + <Button.Content> |
| 47 | + <DockPanel> |
| 48 | + <materialDesign:PackIcon Kind="HelpCircle" DockPanel.Dock="Left" Foreground="White" Height="25" Width="25" Margin="-3 0" Padding="0" /> |
| 49 | + <TextBlock Text="Help" VerticalAlignment="Center" Margin="20 5" /> |
| 50 | + </DockPanel> |
| 51 | + </Button.Content> |
| 52 | + </Button> |
| 53 | + </Grid> |
| 54 | + <Grid ToolTip="Settings"> |
| 55 | + <Button x:Name="ButtonOpenSettings" Margin="0" Height="50" Width="200" Background="{x:Null}" BorderBrush="{x:Null}" HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalAlignment="Center" Click="ButtonOpenSettings_Click" > |
| 56 | + <Button.Content> |
| 57 | + <DockPanel> |
| 58 | + <materialDesign:PackIcon Kind="Settings" DockPanel.Dock="Left" Foreground="White" Height="25" Width="25" Margin="-3 0" Padding="0" /> |
| 59 | + <TextBlock Text="Settings" VerticalAlignment="Center" Margin="20 5" /> |
| 60 | + </DockPanel> |
| 61 | + </Button.Content> |
| 62 | + </Button> |
| 63 | + </Grid> |
| 64 | + </StackPanel> |
| 65 | + </Grid> |
| 66 | + |
| 67 | + <Grid Height="50" RenderTransformOrigin="0.3,0.3" DockPanel.Dock="Top"> |
| 68 | + <Button x:Name="ButtonOpenMenu" Margin="0" Height="50" Width="50" Background="{x:Null}" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="ButtonOpenMenu_Click"> |
| 69 | + <materialDesign:PackIcon Kind="Menu" Foreground="White" Height="25" Width="25" Margin="-10" Padding="0" /> |
| 70 | + </Button> |
| 71 | + <Button x:Name="ButtonCloseMenu" Visibility="Collapsed" Margin="0" Height="50" Width="50" Background="{x:Null}" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="ButtonCloseMenu_Click"> |
| 72 | + <materialDesign:PackIcon Kind="Menu" Foreground="White" Height="25" Width="25" Margin="-10" Padding="0" /> |
| 73 | + </Button> |
| 74 | + </Grid> |
| 75 | + |
| 76 | + <ListView x:Name="ListViewMenu" Foreground="White" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectionChanged="ListViewMenu_SelectionChanged"> |
| 77 | + <ListViewItem Height="50" ToolTip="Inventory" IsSelected="True"> |
| 78 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 79 | + <materialDesign:PackIcon Kind="PhoneLog" VerticalAlignment="Center" Height="25" Width="25"/> |
| 80 | + <TextBlock Text="Inventory" VerticalAlignment="Center" Margin="15 5" /> |
| 81 | + </StackPanel> |
| 82 | + </ListViewItem> |
| 83 | + <ListViewItem Height="50" ToolTip="Line Tests"> |
| 84 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 85 | + <materialDesign:PackIcon Kind="TestTube" VerticalAlignment="Center" Height="25" Width="25"/> |
| 86 | + <TextBlock Text="Line Tests" VerticalAlignment="Center" Margin="15 5" /> |
| 87 | + </StackPanel> |
| 88 | + </ListViewItem> |
| 89 | + <ListViewItem Height="50" ToolTip="Orders"> |
| 90 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 91 | + <materialDesign:PackIcon Kind="Basket" VerticalAlignment="Center" Height="25" Width="25"/> |
| 92 | + <TextBlock Text="Orders" VerticalAlignment="Center" Margin="15 5" /> |
| 93 | + </StackPanel> |
| 94 | + </ListViewItem> |
| 95 | + <ListViewItem Height="50" ToolTip="Bulk Edits"> |
| 96 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 97 | + <materialDesign:PackIcon Kind="AutoFix" VerticalAlignment="Center" Height="25" Width="25"/> |
| 98 | + <TextBlock Text="Bulk Edits" VerticalAlignment="Center" Margin="15 5" /> |
| 99 | + </StackPanel> |
| 100 | + </ListViewItem> |
| 101 | + <ListViewItem Height="50" ToolTip="Telcos"> |
| 102 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 103 | + <materialDesign:PackIcon Kind="RadioTower" VerticalAlignment="Center" Height="25" Width="25"/> |
| 104 | + <TextBlock Text="Telcos" VerticalAlignment="Center" Margin="15 5" /> |
| 105 | + </StackPanel> |
| 106 | + </ListViewItem> |
| 107 | + <ListViewItem Height="50" ToolTip="CMS Locations"> |
| 108 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 109 | + <materialDesign:PackIcon Kind="Compass" VerticalAlignment="Center" Height="25" Width="25"/> |
| 110 | + <TextBlock Text="CMS Locations" VerticalAlignment="Center" Margin="15 5" /> |
| 111 | + </StackPanel> |
| 112 | + </ListViewItem> |
| 113 | + <ListViewItem Height="50" ToolTip="CMS Profiles"> |
| 114 | + <StackPanel Orientation="Horizontal" Margin="5,0,0,0"> |
| 115 | + <materialDesign:PackIcon Kind="Compare" VerticalAlignment="Center" Height="25" Width="25"/> |
| 116 | + <TextBlock Text="CMS Profiles" VerticalAlignment="Center" Margin="15 5" /> |
| 117 | + </StackPanel> |
| 118 | + </ListViewItem> |
| 119 | + </ListView> |
| 120 | + </DockPanel> |
| 121 | + </Grid> |
| 122 | + </Grid> |
| 123 | +</Window> |
0 commit comments