Click here to Skip to main content
15,889,651 members
Articles / Desktop Programming / Universal Windows Platform
Article

Programming Windows 10: UWP Focus (1 of N)

Rate me:
Please Sign up or sign in to vote.
4.81/5 (19 votes)
20 Nov 2017CPOL10 min read 30.7K   39   14
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)


Written By
Software Developer (Senior) RADDev Publishing
United States United States
"Everything should be made as simple as possible, but not simpler."

Comments and Discussions

 
QuestionIt's not WinForm and it's not 10 years old... Pin
netizenk5-Dec-17 5:49
professionalnetizenk5-Dec-17 5:49 
AnswerRe: It's not WinForm and it's not 10 years old... Pin
raddevus5-Dec-17 8:10
mvaraddevus5-Dec-17 8:10 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
netizenk6-Dec-17 10:14
professionalnetizenk6-Dec-17 10:14 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
raddevus7-Dec-17 2:44
mvaraddevus7-Dec-17 2:44 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
netizenk7-Dec-17 5:51
professionalnetizenk7-Dec-17 5:51 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
raddevus7-Dec-17 8:25
mvaraddevus7-Dec-17 8:25 
netizenk wrote:
I'm sure you realize your observations of how much Winforms is still used is based on a very low sample and I realize my observation on how many shops are using WPF would also be based on a very low sample.

I agree on both accounts.
Your research data seems fair to me -- and is very interesting.
netizenk wrote:
Also, not sure what you meant when you said WPF only runs on Windows 8.1 or later since that is clearly not the case,

Again, I attempted to summarize a lot so I've fallen into a place where I haven't stated exactly how things are and then my statements become so unspecific it sounds like I'm saying WPF isn't supported any more. I didn't mean to do that.

I'm actually blaming Microsoft on this too.
Here's what happened.
My Story Is Really About Deployment
I wrote an app C'YaPass as a WinForms app to get it done quickly.
After that I wrote it as an Android App, iOS app, Web app.
I wanted it to be available on every platform.

In that time, Win10 released and when people went to install my WinForm app on their computers they'd see that ugly / scary warning because the app wasn't signed -- I'm too cheap / broke to buy a code-signing certificate.

At that point, I fired up Studio 2015 and began creating what was called a UWP and it was based on WPF. I unwittingly believed it would allow me to deploy easily to Windows but then I found Universal ain't so Universal at all.

As a matter of fact, if you try to open that project in VStudio 2017 it wants you to install the WPF foundation stuff and you cannot deploy to Windows Store.

My main point of this is Microsoft's future way that they are pushing us towards (at this moment and they often change direction instantly) -- if you want to easily deploy to desktops outside of your main Enterprise is to create a UWP.
If you create a UWP then you can get vetted as a dev --- I think it's only $25 sign up fee.
Then once your UWP app is done, you can point people to your app in the Windows Store and they can easily install it.

That's my main point. Most users don't know what this terrible warning is --- check out the image of the popup, it is very confusing:
http://cyapass.com/content/images/install/installer1.png[^]

Do you see that "More info" text? It's actually a link and most users don't even notice it.
They just think the app is bad or dangerous.

Even if they get more info then they see the second dialog:
http://cyapass.com/content/images/install/installer2.png[^]
And it's not great either.

Anyways, these were my two main points:
1. Win10 is taking over -- if you want to create and deploy desktop apps probably need to consider UWP -- but how feasible is it?
2. WinForms are quite old -- really even before they were called WinForms the controls were still there via the Windows API and a lot of those controls haven't really changed much since win95. Since that is old and you need to move to a new technology, might be a good idea to begin to move to UWP since even Visual Studio is forcing things that way.

That was it.
Again, I think this is a great discussion. Thumbs Up | :thumbsup:

Hopefully, my points finally make more sense. Now, if I had included this kind of discussion in the originally article, most people would've been like "what're you talkin' about" and/or "this is a boring history article". Smile | :)

EDIT
Also read this article here at CP which was highly upvoted and is from way back in 2014 -- meaning it may be more signficiant now:

Is WPF dead: the present and future of WPF[^]

modified 7-Dec-17 17:06pm.

GeneralRe: It's not WinForm and it's not 10 years old... Pin
netizenk7-Dec-17 12:22
professionalnetizenk7-Dec-17 12:22 
GeneralRe: It's not WinForm and it's not 10 years old... Pin
noending24-Oct-18 22:12
noending24-Oct-18 22:12 
QuestionInstallation Pin
Calvin1121-Nov-17 5:06
Calvin1121-Nov-17 5:06 
AnswerRe: Installation Pin
raddevus21-Nov-17 5:24
mvaraddevus21-Nov-17 5:24 
AnswerRe: Installation Pin
raddevus21-Nov-17 5:27
mvaraddevus21-Nov-17 5:27 
GeneralRe: Installation Pin
Calvin1121-Nov-17 5:48
Calvin1121-Nov-17 5:48 
GeneralMy vote of 5 Pin
Franc Morales20-Nov-17 15:33
Franc Morales20-Nov-17 15:33 
GeneralRe: My vote of 5 Pin
raddevus21-Nov-17 2:04
mvaraddevus21-Nov-17 2: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.