How to Make your First Windows 10 App

Because Windows has been slowly transitioning from one app model to another, I found it tricky at first to find Windows 10 specific resources. I started playing around with the Windows 10 specific universal app creation tools recently. Now I’m creating this quick guide to help you make your very first simple Hello World app targeting Windows 10. Hopefully you’ll find this quickstart useful, and then you can move on to using some more complex samples to create more complex apps.

1. Open up Visual Studio 2015. (Community 2015 here is free.)

2. In the file menu, choose New Project – > BlankApp Universal Windows.

3. Name the new project HelloWin10. At least, that’s what I did. What you name things initially in XAML is important because references use exact names and if you can’t keep track of names things will be broken. So be sure that whatever you call it you’re comfortable with still using it throughout the project. If you choose to call it something else, make sure that you replace any references to HelloWin10 in the code below.

4. In your MainPage.xaml.cs have this code:

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;


namespace HelloWin10
{
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
}


private void HelloButton_Click(object sender, RoutedEventArgs e)
{
DisplayText.Text = "Hello, world";
}
}
}

5. In your MainPage.xaml have this code:

<Page x:Class=”HelloWin10.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:local=”using:HelloWin10″
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″
mc:Ignorable=”d”>

<Grid Background=”{StaticResource ApplicationPageBackgroundThemeBrush}”>

<StackPanel>

<Button Content=”Click Me” Click=”HelloButton_Click” />

<TextBlock x:Name=”DisplayText” FontSize=”48″ />

</StackPanel>

</Grid>

</Page>

6. Test your app by clicking the green arrow or going to Debug. An app screen should appear (if you are on Windows 10). Here the Click Me button calls HelloButton_Click so it displays the text Hello World.

Yeah, so it’s not much of an app, but you gotta start somewhere. In the future I’ll make some more robust apps using data from the web and from Azure and show you those processes too. I’m working out of these files on GitHub and I’ll create a few branches. If you see that the code on GitHub has a little more in it than just Hello World, that’s because I’ve also integrated Template 10 by Jerry Nixon which has a few additional features. It’s not necessary to get started, though!

For learning more about C#/XAML, check out Virtual Academy.


Posted

in

by

Tags:

Comments

One response to “How to Make your First Windows 10 App”

  1. Christopher Avatar

    Having a great tech Blog post is always appreciable. Much appreciate the efforts. I will try these to foucs On my blog, My Blog here

Leave a Reply

Your email address will not be published. Required fields are marked *