Here’s the classic Hello World example used to introduce many programing languages and frameworks – in this case it’s an introduction to the Universal Windows Platform which features a simple application to display a message on screen when a Button is tapped.
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 find and select Visual Studio 2017.
Step 2
Once Visual Studio Community 2017 has started, from the Menu choose File, then New then 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
Step 4
Then in New Universal Windows Project you need to select the Target Version this should be at least the Windows 10 Fall Creators Update (10.0; Build 16299) and the Minimum Version to be the same.
The Target Version will control what features your application can use in Windows 10 so by picking the most recent version you’ll be able to take advantage of those features. To make sure you always have the most recent version, in Visual Studio 2017 select Tools Extensions and Updates… then and then see if there are any Updates
Step 5
In the Solution Explorer select MainPage.xaml
Step 6
From the Menu choose View and then Designer
Step 7
Then from the Toolbox in Common XAML Controls, double-click or double-tap Button to add it to the Design View
The MainPage.xaml is what the application will look like, by placing a Control on to the Design View you can make up the look of an application
Step 8
When the Button has been added to the Design View go to Properties and set the Content to Display and HorizontalAlignment to Center and VerticalAlignment to Center
The Button will appear in the middle of the Design View once these Properties have been set with the Content of Display
Step 9
While still in the Properties select Events and then set Click to Button_Click then either double-click on the text or press Enter once the value is typed in
Step 10
Once done the Code View should be displayed, inside private void Button_Click(object sender, RoutedEventArgs e) { … } the following Code should be entered:
await new Windows.UI.Popups.MessageDialog("Hello World").ShowAsync();
While still in the Code View in between private and void enter the following:
async
It should then appear as such:
When the Button_Click is triggered, by Clicking on the Button the Application will display a MessageDialog with the Text Hello World – since this is an asynchronous method it requires async
Step 11
That completes the Universal Windows Platform Application so Save the Project then in Visual Studio select the Local Machine to run the Application
Step 12
Once the Application has started running you can then select Display to show a MessageDialog with Hello World that can be dismissed with Close
Step 13
To Exit the Application select the Close button in the top right of the Application