Windows 10 – Universal Windows Platform – Hamburger Menu

Step 1

Download Visual Studio Community 2015 and install it onto your computer, if it’s already downloaded and installed select Launch to start Visual Studio Community 2015 or if it has already been downloaded and installed then start the application you may also need to Enable your device for development.

2015-visual-studio

Step 2

Once Visual Studio Community 2015 has started select File, then New, then Project… from the Menu.

2015-file-new-project

Step 3

From the New Project window select Visual C# from Installed, Templates then select Blank App (Windows Universal) from the list, then type in a Name and select a Location to save to before selecting Ok to create the Project.

2015-new-project

Step 4

Then from the Solution Explorer select MainPage.xaml

2015-mainpage-library

Step 5

Select from the Menu, View then Designer

2015-view-designer

Step 6

The Design View will be displayed along with the XAML View and in this replace <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”></Grid> with the following XAML:

<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
	<Button x:Name="Hamburger" Background="Transparent" Margin="0,5" Click="Show_Click">
		<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" FontSize="28"/>
	</Button>
	<SplitView x:Name="SplitView" PaneBackground="{ThemeResource ApplicationPageBackgroundThemeBrush}" 
		RelativePanel.AlignRightWithPanel="True" 
		RelativePanel.AlignLeftWithPanel="True" 
		RelativePanel.AlignBottomWithPanel="True"
		RelativePanel.Below="Hamburger">
		<SplitView.Pane>
			<RelativePanel Background="{ThemeResource AppBarBackgroundThemeBrush}">
				<AppBarButton Name="Hide" Icon="Cancel" Label="Hide" Click="Show_Click"/>
			</RelativePanel>
		</SplitView.Pane>
	</SplitView>
	<VisualStateManager.VisualStateGroups>
		<VisualStateGroup>
			<VisualState>
				<VisualState.StateTriggers>
					<AdaptiveTrigger MinWindowWidth="720"/>
				</VisualState.StateTriggers>
				<VisualState.Setters>
					<Setter Target="SplitView.DisplayMode" Value="Inline" />
					<Setter Target="SplitView.IsPaneOpen" Value="True" />
				</VisualState.Setters>
			</VisualState>
			<VisualState>
				<VisualState.StateTriggers>
					<AdaptiveTrigger MinWindowWidth="0" />
				</VisualState.StateTriggers>
				<VisualState.Setters>
					<Setter Target="SplitView.DisplayMode" Value="Overlay" />
					<Setter Target="SplitView.IsPaneOpen" Value="False" />
				</VisualState.Setters>
			</VisualState>
		</VisualStateGroup>
	</VisualStateManager.VisualStateGroups>
</RelativePanel>

It should appear as such:

2015-hamburger-menu-mainpage-xaml

Step 7

Select from the Menu, View then Code

2015-view-code

Step 8

Once in the Code View below the public MainPage() { … } the following should be entered:

private void Show_Click(object sender, RoutedEventArgs e)
{
	SplitView.IsPaneOpen = !SplitView.IsPaneOpen;
}

It should then appear as such:

2015-hamburger-menu-mainpage-code

Step 9

That completes the Universal Windows Application so Save the Project then select the Debug and Simulator option to run the Application

2015-simulator

Step 10

Once the Simulator has started the Application should then appear

2015-hamburger-menu-simulator-run

Step 11

After the Application has started running you can then tap the Hamburger button to show or hide the Hamburger Menu or resize the Window

2015-hamburger-menu-simulator-run

Step 12

To Exit the application select Stop Debugging in Visual Studio Community 2015

2015-stop

Step 13

Another option is to run as a Windows 10 Mobile application, select Debug and select Emulator 10.0.10586.0 WVGA 4 inch 512MB option to run the Application

2015-emulator

Step 14

Once the Emulator has started the Application should then appear

2015-hamburger-menu-emulator-run

Step 15

After the Application has started running you can then tap the Hamburger button to show or hide the Hamburger Menu

2015-hamburger-menu-emulator-ran

Step 16

To Exit the application select Stop Debugging in Visual Studio Community 2015

2015-stop

Creative Commons License

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s