Universal Windows Platform – Access Keys

Step 1

If not already, follow Setup and Start on how to Install and get Started with Visual Studio 2017 or in Windows 10 choose Start, and then from the Start Menu locate and select Visual Studio 2017.

vs2017-home

Step 2

Once Visual Studio Community 2017 has started, from the Menu choose File, then New then Project…

vs2017-file-new-project

Step 3

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

vs2017-new-project

Step 4

Then in New Universal Windows Project you need to select the Target Version to be Windows 10 Creators Update (10.0; Build 15063) and the Minimum Version to be at least Windows 10 Anniversary Update (10.0; Build 14393) or Windows 10 Creators Update (10.0; Build 15063)

vs2017-platform

Step 5

In the Solution Explorer select MainPage.xaml

vs2017-mainpage

Step 6

From the Menu choose View and then Designer

vs2017-view-designer

Step 7

The Design View will be displayed along with the XAML View and in this between the Grid and /Grid elements, enter the following XAML:

<CommandBar IsOpen="True" VerticalAlignment="Bottom">
	<AppBarButton Icon="Bold" Label="Bold" AccessKey="B" Click="Button_Click"/>
	<AppBarButton Icon="Italic" Label="Italic" AccessKey="I" Click="Button_Click" />
	<AppBarButton Icon="Underline" Label="Underline" AccessKey="U"  Click="Button_Click"/>
</CommandBar>

It should appear as such:

xaml-access-keys

Step 8

From the Menu choose View and then Code

vs2017-view-code

Step 9

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

private async void Button_Click(object sender, RoutedEventArgs e)
{
	AppBarButton appbarbutton = (AppBarButton)sender;
	await new Windows.UI.Popups.MessageDialog($"Button: {appbarbutton.Label}").ShowAsync();
}

It should then appear as such:

code-access-keys

Step 10

That completes the Universal Windows Application so Save the Project then in Visual Studio select the Local Machine to run the Application

vs2017-debug

Step 11

Once started the Application should then appear

run-access-keys

Step 12

After the Application has started running you can then press Alt on your Keyboard to show the access keys for the commands on the Command Bar

ran-access-keys

Step 13

To Exit the application select Stop in Visual Studio

vs2017-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