Click here to Skip to main content
13,800,398 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

14.8K views
36 bookmarked
Posted 20 Nov 2017
Licenced CPOL

Programming Windows 10: UWP Focus (1 of N)

, 20 Nov 2017
Rate this:
Please Sign up or sign in to vote.
Using C# for Desktop Development: Get Started in UWP (moving away from WinForm) --Intro & Chapter 1

Introduction

Programming Windows 10

Alice's Adventures In Wonderland (Lewis Carroll)
The White Rabbit put on his spectacles. "Where shall I begin, please your Majesty?" he asked.
"Begin at the beginning," the King said gravely, "and go on till you come to the end: then stop."

What Is the Focus of Programming Windows 10?

My focus here is on creating UWAs (Universal Windows Apps) with a focus on creating apps for the Windows 10 desktop.  Yes, _The Modern Dream_ is to develop an app and deploy it to any type of device (PC, laptop, pad (Surface), phone or whatever).  However, the focus here in this book (series of articles) is creating desktop apps that will keep those other platforms in mind but not focus directly on them.

Why UWA For Desktop Apps?

Your question could be why we would focus on UWA / UWP (Universal Windows Platform) if we are focusing on Windows desktop.  Shouldn’t we just use Windows Forms or something?  Well, the advantage of creating a UWA (Universal Windows App) is that if you want to deploy it you can easily sign up for a Windows Developer account and get your app into the store.  That is my focus because if you want to install an app on users’ desktops these days it is quite a bit more difficult due to security concerns.  If you create a UWA and deploy it to the Windows Store then they vet your app and users will know it is safe for installation.

Also, isn't it about time we all moved away from WinForm apps?  WinForm technology is at least ten years old and most of it is much older. 

UWP For All: Feasible?

But, is it feasible to move entirely away from WinForms and over to UWP for desktop apps?  This guide will investigate that also.

Which Programming Language Will We Focus On?

This book will use C# exclusively for all code.  There’s not that much difference in learning Visual Basic as opposed to C# anyways and C# is used far more often in Enterprise apps.  Also, if you learn C# you can always learn Visual Basic.NET later (if need be and hopefully there will never be a need).  

Background

I'd simply like a modern Windows Desktop Programming guide which focuses on UWP and "...begins at the beginning and goes on from there, until it gets to an end, then stops".

Who Is the Book (Article Series) For?

I'm really hoping that the book can be used by beginners who are new to building apps and also beginners who are new to building apps as UWAs (Universal Windows Apps). 

Additionally, I'm hoping to build a narrative which guides readers into more advanced subjects so that the book (series of articles) can also be used by intermediate and advanced devs to learn UWP (Universal Windows Platform) development.

With that, let’s get started Programming Windows 10.  Of course, to build our first Windows 10 app, we’ll have to get Visual Studio.  After that, we’ll be able to build our first project based upon a Visual Studio template.  Once we get that template project, we will tear it apart and look at it in detail to discover the guidance that Microsoft attempts to provide.

Let’s go get Visual Studio.

Chapter 1

Gathering Your Tools

If we were carpenters setting out to frame a house we would find it necessary to :

  1. Gather required tools (hammers, saws, etc.)
  2. Gather our materials (wood, nails, screws, hinges, etc)
  3. Create a plan for our finished house

As computer programmers we need to do the same three things.  

In this chapter we’ll focus on the first two items specifically and as we move through the book you’ll see we continually come back to the third item (planning).

Since software is basically virtual (you can’t really touch it), it may seem a bit confusing where to look for our tools.  Also, since you may be new to the world programming it may be confusing to know which tool is appropriate for the job.

If you search the Internet you may find all kinds of advice for developing Windows applications (Python, Xamarin, etc.).  However, we are going to use Visual Studio which is probably the most obvious choice. 

Microsoft provides Visual Studio Community edition at no charge.  All you need is an Internet connection and you can download and install it.

Where Do We Get Visual Studio?
You can point your browser at:
Free IDE and Developer Tools | Visual Studio Community[^]

When you get there you will see something like the following:

get visual studio home page


Click the [Download VS Community 2017] button to get started.

When I clicked that button Google Chrome popped up a window asking me where I wanted to save the target file:

VStudio install step one

 

When I selected the default location, Chrome opened its normal bar at the bottom of the browser.

VStudio download

 

I clicked the up (^) arrow and selected Open, which starts the Visual Studio installer.

 

Google up arrow


User Account Control (UAC), the Windows built-in system protection, will make sure you want to allow the installer to run on your system.

UAC warning

Click the [Yes] button to continue.

You may see a dialog like the following (depending on how fast it goes) appear as Visual Studio unzips and copies files:

unzipping files


Then you should see Visual Studio confirm that you want to Continue the installation.

continue install

 

Click the [Continue] button to allow Visual Studio to take more actions.

 

You’ll see a window letting you know Visual Studio is working.

install is working

Finally a large window will appear so you can choose what you want to install.

choose items to install

We could just choose the first one, however, let’s get everything set up in case we want to write a quick console app later too.  Go ahead and choose the first two items, by selecting their checkboxes on the right as shown in the next image.

items are selected for install

 

You can see on the right that the items listed for developing Universal Windows Apps is included.  You also see (at the bottom of the window) that it has chosen a default location to install Visual Studio.  Just accept that location and click the Install button on the bottom right.

9.3 GB May Take Some Time

Depending upon your Internet connection speed and your computer that will take quite a bit of time.  It’s something like 9.3GB of data to download so it can take a while.

That’s another reason it’s good to get it out of the way first thing.  

As it runs it will let you know the status which looks something like the following:

installation status

The good news is that this is a one-time thing and once it is installed you will only have to install updates later.

Installation Complete

Once the installation is complete, you will see the following:

installation complete

Starting Visual Studio 

Click the [Launch] button to start Visual Studio Community 2017 for the first time.

preparing for first use

Microsoft Developer Account - Not Required

The first thing you will see is a dialog asking you to sign in with your Microsoft developer account.  You can also create a new developer account if you like.  I believe Microsoft helps you keep your settings across multiple computers with the account.  Also you get mailings and other interesting items with that account if you like.  You do not have to sign in or create an account at this time.  I’ll let you work that out for yourself.  If you want to continue for now without creating an account just click the “Not now, maybe later” link.

dev account requests sign-in

Visual Studio Color Preferences


After that you’ll see a dialog (which I didn't capture) which will allow you choose some color preferences for the Visual Studio environment.  If you’ve never seen Visual Studio before you probably have little idea about what you might prefer.  You can always change these later so for now just choose the default (already chosen) Blue choice and click the [Start Visual Studio] button.

After that, you’ll see something like the following as Visual Studio starts for the first time.

 

####################################################################################

Sidebar - Why You Need to Create a Developer Account

Since I was installing Visual Studio 2017 on a machine where I had previously installed when I started Visual Studio after ignoring the chance to sign in with my developer account I was greeted with the following dialog box which requires me to sign in.

dev account required

Apparently Microsoft gives you a 30-day trial and after that you have to register as a developer.
That seems like a fair trade to me, since Visual Studio provides so much for free for Students, Open Source devs and Individual developers.  After signing in with my account I was able to continue to use Visual Studio.

####################################################################################

####################################################################################

SideBar 2 : Setting up Windows 10 For UWA Development

As you are installing Visual Studio or possibly after you may see a window appear which looks like the following:

win10 settings

Most likely, yours will still be set to ( * ) Windows Store apps.  Make sure you choose Developer mode.  This will allow Visual Studio to install the app directly on your machine we expect it to.  These settings are intended to create a more secure Windows installation so that you cannot accidentally install a UWA that has not been approved by the Windows Store vetting process. 
In our case, we want to be able to install the app each time we build it as we are developing it and the Developer Mode will allow that.

If this setting isn’t changed you may find later when we build and run the app that Visual Studio takes you to this window so you can decide if you want to make the change.

If you want to check the setting, you can click the Windows Start button and type “developer”.  When you do that you’ll see something like the following:

use developer settings

You can click the Use developer features to get to the setting.
############################################################################


Once Visual Studio starts up for the first time you are going to see something like the following:

vstudio first open


There’s a lot in Visual Studio and your eyes kind of wander around trying to determine what is important.  For now there are three main areas to initially focus on shown in the next image.

studio focus here

1 -- The Toolbox will become important when we begin looking for Windows controls we want to drop on forms.  Windows controls are things like list boxes, treeviews, buttons, checkboxes and other common things we use to design our User Interface(UI).  When you click the Toolbox tab later, you will see it pop out into a new window.

2  -- The next thing to take note of is the main menu.  Everything you need to get to is located somewhere in this menu.  That is where we will begin our work in chapter 2 when we start a new UWA (Universal Windows App).  We will go to File...New… so that we can have Visual Studio help us start a new project.

3 -- Finally, when a project loads up, there is a always more than one file and folder associated with the project and all those files are called our Solution.  The Solution Explorer on the right side will be populated with a treeview that will show us the folders and files that are included in our project.

Here’s a quick preview of what Visual Studio will look like when a project is loaded.  

first project loaded

On the left, you can see that the Toolbox is now filled with various controls that can be chosen and on the right the Solution Explorer now contains a treeview populated with the various parts of the solution.

We will see this in action in the next chapter when we build our first project. 
We’ve covered quite a bit in this chapter and now we are all set to start our first application and look at some code. 

Points of Interest

If nothing else, this intro and Chapter 1 has provided an overview of what you will go through when you install Visual Studio 2017.

History

11/20/2017 - First publication of the article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

raddevus
Software Developer (Senior) RADDev Publishing
United States United States
The CP editors went to Canada and all I got was this crummy sig line.
My web site, blog and other dev projects including C'YaPass : http://raddev.us^

You may also be interested in...

Comments and Discussions

 
QuestionIt's not WinForm and it's not 10 years old... Pin
netizenk5-Dec-17 6:49
professionalnetizenk5-Dec-17 6:49 
AnswerRe: It's not WinForm and it's not 10 years old... Pin
raddevus5-Dec-17 9:10
mvpraddevus5-Dec-17 9:10 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
netizenk6-Dec-17 11:14
professionalnetizenk6-Dec-17 11:14 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
raddevus7-Dec-17 3:44
mvpraddevus7-Dec-17 3:44 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
netizenk7-Dec-17 6:51
professionalnetizenk7-Dec-17 6:51 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
raddevus7-Dec-17 9:25
mvpraddevus7-Dec-17 9:25 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
netizenk7-Dec-17 13:22
professionalnetizenk7-Dec-17 13:22 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
noending24-Oct-18 23:12
membernoending24-Oct-18 23:12 
QuestionInstallation Pin
Calvin1121-Nov-17 6:06
memberCalvin1121-Nov-17 6:06 
AnswerRe: Installation Pin
raddevus21-Nov-17 6:24
mvpraddevus21-Nov-17 6:24 
AnswerRe: Installation Pin
raddevus21-Nov-17 6:27
mvpraddevus21-Nov-17 6:27 
GeneralRe: Installation Pin
Calvin1121-Nov-17 6:48
memberCalvin1121-Nov-17 6:48 
GeneralMy vote of 5 Pin
Franc Morales20-Nov-17 16:33
memberFranc Morales20-Nov-17 16:33 
GeneralRe: My vote of 5 Pin
raddevus21-Nov-17 3:04
mvpraddevus21-Nov-17 3:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181214.1 | Last Updated 20 Nov 2017
Article Copyright 2017 by raddevus
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid