SK125 Foundation: Get started building modern Windows 10 apps
Is Key or for, example I work with a, lot. Of music application, developers, and those music application, developers, need to have their applications, have really, low latency access, to, the audio stack, and windows and they need to be able to talk directly to drivers, and they need to be able to load. External, dll's, directly, into the process, so that they can. Operate as. As. Plugins vsts, in most cases here those types of applications clearly. A native application is. Going to give them the most flexibility. In those cases. Alright. Now that I've convinced, you that native applications, are still a thing on Windows let. Me tell you about some of the investments, that were making to support native, application, developers. We. Have, so. This is not a comprehensive slide we have lots, of ways of building applications, on windows and not, all of them are created by us there are third parties, who create their own languages, and frameworks and, tools which. Work perfectly, well for building, native applications, on Windows but I do want to focus here on just a few of these so. The first is dotnet. In, c-sharp or even Visual Basic applications. If you, want to build an application that has kind of a classic, windows, UI the stuff, that, we usually think of with white text boxes and grey backgrounds. Then. You know you're looking at something like a Windows forms application although Windows, forms has come a long way and you can certainly do more stylized applications. It's strength, is really in that native, look and feel to. Be able to build applications that have that kind of very business, focused look, to them and windows, forms is still super popular today so if you're looking for a really easy way to build a native application for, Windows and get started, Windows forms might be the right thing for you to take a look at. Second. If you're building an application that. Is going to run on the console then you know a command-line application we. Have tools for those are we have application. Types for that as well you, can build console, applications, in dotnet you can also build console, applications, in C++. And other technologies, on Windows. Now. If you want one of our you are newer UI stacks in this case is Amal UI right. Now there. Are two places that you can go to get that you, can build a Windows presentation foundation, application. A WPF, app and that, is you know another dotnet, based application. It has the same level of access to the operating system that a windows, forms application has, but, it has a sam'l, UI layer on top of that and then, if you want to use some.
You Can also build, uwp, applications, using C++, WinRT, now, C++, when our teeth like even though I had slash WinRT, init this is standards-based, C++. Everything. Is contained in headers and libraries this, is not you. Know the the C++, C X we had before were the little hats that you had to use for. Dereferencing, pointers and things like that now, this is standards-based, C++, and you, have access to all the UW PAP eyes including the UI layer so you can build a really. High. Performing. C++. Application. With zamel, based UI as. A uwp app using c++ WinRT and also a bunch of other things that you can do with C++ 1rt, as well for different application, types and it. Really, is one of the most flexible way to build applications. Now. I mentioned, a minute ago that. We're. Doing some things to make, the windows UI a little bit more flexible, and use that from other different types of application, types and that's a really important direction that we're taking here if you think so we've had dotnet. And we've had a dotnet framework and dotnet core which are now sort of converged together and tada at five but we've had these different flavors of dotnet, each with their own UI stacks, then, we've had, uwp, applications, with, its own UI stack, in API, level I and, then we have had you know C++ win32. Applications, with MFC. And other technologies, right and all, of those have been separate, silos you couldn't really, there, were some hacky type things you could do to integrate some of them but, you couldn't really do, say a dotnet. Application. That used the the new UWP, zamel, UI layer, and you couldn't do a C++, application. That, use the same thing right like we. Had all of these different UI, layers were very highly, tied, to. The framework, that, they were built around. So. Why do why, would we do that right there's just sort of the way that they grew up right. We don't wanna this. Isn't something necessarily, that we set out from at the beginning to say yes we're gonna create all these different siloed you eyes but as these came up in different, periods. In history and. And.net. Like windows forms is you, know from, 2001. Or somewhere. Right around that that range was was. Windows forms 1.0, so it's actually got some it's. Been around for a little bit right and WPF, is around. The the Windows Vista timeframe before I remember correctly so these have all been around, for a long time and they've come up at different points in history and. As. Such they have been each developed, independently, and then sort of kept to their own silos, and that's. Just not the way developers, want to build applications today. So. You WP and the Windows 10 developer, platform all up in Windows 10 or evolving. We are decoupling. The parts we are making them more modular, and. So, that's really great so you'll be able to now take you, know later this year the the, UI. Stack, for Windows and you can package that with your application, you don't have to worry about you, know which version of Windows am i installing this application, on right does that have the right UI controls, that I want when I said we're lifting, that whole piece up all of those different api's bundling. Them together and making them so that you can take them with you with your applications, and you don't have to be tied to a specific release, of Windows 10 and. You can. Also use, those api's, and use that example and use that UI layer, from, all the different languages in Windows, so.
You Can even use that UI from. Say Windows forms so if you want to have you, know although the windows forms greatness, that you have been you. Know using for a long time or in your new application, and incorporate, little islands of functionality, that are from. The UW Pui, stack, you can do that and that's. All part of something that, we're calling project, reunion, now there's other there, are other, sessions here at build this year that go into much more depth than that so I'm not gonna kind, of steal all their thunder here today but, do seek those out again all the resources. For that are in the resource links. So. Now I think the best thing to do is to just hop, into a demo and show, you the some, of the different, ways that you can get started building applications. Today, now. A really good place to start is actually our documentation. So, if, you go to developer. Microsoft, comm or if you go to dev windows.com. Or any of those other aliases, it's going to bring you here to the Microsoft, developer page, and on, this page you're gonna see there are a whole bunch of getting started tutorials, for you so if you want to start building web applications or, mobile applications, or if you want to learn how to work with AI, with, the the. Tools that we have available for that or build, BOTS or build IOT applications, it's all right here now. I'm going to click on Windows apps cuz that's what we're talking about here today and that brings you over to, the, Windows app developer, documentation oh notice. There's an ad for Microsoft, build I hope you're enjoying Microsoft. Build don't, forget to register now, if, we go over here and look there are different types of Windows applications. That you can build or desktop applications. We, also have, a, section, here on WSL. I talked. Very briefly about WSL in my other video but I think it's totally worth checking out if you have even the slightest inclination to, do anything with Linux on Windows it's, super fun it's actually one of my favorite tools that's in the release of Windows that I'm that I'm using here today 2004. Now. If I want. To go down a little bit further here it goes through the different frameworks. That we have now, I had mentioned earlier when, 32 apps WPF. Apps windows, forms apps and uwp and coincidentally. That's exactly, the the. Set of things. That are listed here so, if I go into UWP, because that's where we're gonna go over in just a second if I click on an overview you're gonna see there's tons of documentation, here like it, brings you all the way from if, you are brand new to uwp all the way through to you know if you need to complete, some. More, advanced. Advanced. Tutorials, so that you can further, your knowledge of something like uwp all, right so that's super useful I'm.
Not Gonna go through these particular, tutorials. Here today but I do have something fun planned, as. Our visual studio open here and I, am going to create, a new, project and. That. New project is going to be a universal. Windows application. We'll get to the other application, types here shortly and, that's gonna be in c-sharp and you see here like when, you are in Visual, Studio and by the way you can use the free version of, Visual Studio which, is free. For our small, developers. Are open source individuals. Etc the Community Edition you, can use that to build these types of applications, so, but when I create a new project here I get, all the different types of projects. That Visual Studio can, create and what. Gets listed here depends, upon what you setup, in Visual, Studio to begin, with or what you have added later via the Visual, Studio installer. In. This case I'm gonna like I said create a blank application and, hit next, and. I'm going to now configure. This project I'm just gonna leave the name you, know the, simple. Name here and then I am going to change the location here to see. Demos. Just to keep my repos folder, clean and I want to clutter up all my github stuff and the. Solution, name is going to be app 1 if. You're brand-new to visual studio and dotnet applications, in, particular you. Have a solution, and that solution can. Contain multiple projects. And. The, solution, has its own name that's separate from the project name the solution name doesn't really matter it's good to name, it something meaningful. But it's really the project name that is going to automatically, set up things like the executable, name the application title, etc so, that's the one that you want to make sure it has a little bit more something. Useful so, I can say graph. Demo. Here as the, project name you see it's that the solution name is the same but. That doesn't really matter, and. So I am going to hit create. Now. This. Is one of the first decisions that, you're really going to run into when you build a uwp application, what, a version, of. The. Of. The SDK, do I want to use to, build the ewp application, well that. Is really and, again this will change a little bit later with some of the things we're doing to. Reunite. All the different api's, but. What this is telling you is what version, of Windows is. The minimum, version that you're gonna support our SDK, versions, and our Windows versions are pretty much one-to-one, so, I can say the minimum version of Windows are going to support is I'm. Gonna say 1903. Here right and. The target version is also going to be 1903. So that's you know just a couple of releases back. What. This controls, is what API is you have access to and what you know kind of what the behavior of those API czar so, if you have excuse. Me yes so, if we. Introduce a new feature in 1909. That, has a new API associated. With it but you are targeting, 1903. Your, application, is not going to use that, API, it's, going to be you know kind of locked to the 1903, api's, and then you can increase, this number each.
Time That you build the application if you want to you, know reassess. This and use. One of the later SDKs, you're certainly capable are, enable to do that. Able. Not unable excuse me all. Right so now it's going to create the application. And. Here we go so this is a, uwp, application, and I'd mentioned that it uses sam'l, so, if I go over here there's, a sample, page. Called main page sam'l. And. You see it pops up and this is as you can imagine the, main page for the application now. There are all sorts of controls that I have over here that I can drop in, into. This page but, also if if I don't want to work in the text side I I type. Sample by hand I tend not to use the designer so I spend a lot of time here so I haven't defaulted, to always opening, in this view but, there is a designer, so if I click on the designer page and. I, want to say fit the whole page here, I guess, they fit all you, see that and, I'm, gonna go down here and I'm going to drag in a text, block, and what, a text block is is, just a way of displaying text, in, our application. I can you. Know mess with all the properties over here into the designer again, this is super easy if you're looking to explore and figure out you, know how. The property, system works for zamel applications, I can, say I want 48 point. Excuse me 48 pixels, stego, UI is the font that I'm going to use here etc etc so I can mess with all that stuff and I'm gonna say hello world. For the text and there, you go now if I look at the zamel behind. That what, it's done is its created quite a bit of zamel for me so let me just blow this out a little bit so you can see what we're what we're looking at here, it's. Created a text block which, is the control we dropped in and it, is set it so it's horizontal alignment. Is left, now, that horizontal. Alignment, is based upon the container, that it's in which in this case is a grid which, itself is inside, the page right so, if I go back over to design here I can see that this is based on being. Aligned, from, the left and then, it has this margin. 688. For 6000. That. 688. For, 6000. That. Is controlling, where it exists, on that page I can, simplify this a bit so I can get rid of that margin and I can say horizontal alignment, is Center now. I didn't do any vertical alignment I just said horizontal, alignment, so if I go back to the design view you see I am now centered, horizontally and. Back. To here I can, say, vertical. Alignment. Center. Oh. That, was what the problem was see you can make mistakes too there, yeah so. That it did have a vertical alignment but it was at the top so I have set that to center and here, you see it's centered on the page now, if I were to run this I would see the same thing and no. Matter how I resize, this page or would always stay centered, here mom. On this canvas. Now the same types of, alignment. Controls, and everything there work with, buttons, with, lists, and all sorts of other controls that you would expect to be able to use in an.
Application Like this but, I just wanted to do this simple hello world to, begin with there so again use, the designer or use the, zamel view either way works just, fine for you you, see in this amyl view you can intellisense, that autocompletes. The property names and. If you're in the design view that's, something that's very familiar to Windows forms developers, and folks that want to you know visually, layout, the page as, opposed to hand editing the saml for that and there's. Nothing wrong with either. Approach, either way works just fine it's just whichever, ways you're gonna be the most productive all. Right now. That's not really the demo I want to do here so that was a very simple hello world for zamel, but I want to add in just a little bit more. You. Saw the name of the project was graph demo and, so that that. Is because I want to integrate this application, with the Microsoft, graph I want to provide a little bit of basic functionality, like you might have inside, an enterprise application and. I'm gonna do that the, best coding way possible, I am going to paste in some code so, I are, pasted, markup in this case okay. So, I'm gonna use the clipboard here but annoyingly it wants, to open up outside, of the recording, area that I have for this video which, is bizarre so I just want to show you really quickly the the clipboard. Manager in Windows here, I just, inside notepad so if I hit Windows V right, it, is giving me the. Clipboard history that I have here and so I could, paste in any of the different things and one of those happens, to be the. Zamel. In. This case the, namespaces. For this project and another, one is going to be the sample itself so when I hit Windows V and paste it in understand I'm using the clipboard manager, for that and. Again I have, a gigantic screen here and it's deciding, to open up off to the side so, let me just windows, V that and. I'm gonna add in there's. Our namespaces, and then, I'm gonna replace this whole grid here which is you, know a layout container and I'm gonna windows V that. And I. Am going to replace that with some, wonderful zamel, and that. Zamel here is going to have functionality. For connecting to the graph now, you notice that everything here is coming up with the you, know kind of aqua, colored or, cyan colored squigglies, and that is because I have not yet added the new get package. NuGet. Packages, are a way, of adding. External. Features to your application, to be able to build upon the, work that others have done Microsoft. Releases a lot of features as NuGet packages, but, then you know third parties do as well so I'm going to right click on the project, I say manage NuGet packages, and. It. Defaults to install though I'm gonna go to browse and, I saved Microsoft, toolkits. Graph. Controls, and, you see here's Microsoft toolkit graph controls, I am, going to add that to the project, and this. Is going to provide, a whole bunch of grab, Microsoft, graph related, functionality, for, a uwp, application. Right. Now if I go back to the main page saml. Here. We are you see it cleared up those errors and now. So let me just go through this very quickly since I'm, assuming, that you may in fact be new to zamel in this case here and, the same types of things that I'm discussing, for uwp would apply to WPF. And. Anything else I use as sam'l here so. First, of all we have a. Provider. For the. Microsoft, graph I'm not gonna scroll over to the right because it's got a private application, ID in it that I'd prefer not to have, in. The video but, this is what sets up our connectivity, to the graph you, can do this in code by. Using properties, on the objects but they've also made it possible to plug this directly into zamel so that you don't have to write the code there from. There I have a grid and a grid is a layout container, that. Lets you lay things out on a grid right so you can have rows and columns, and you can constrain, different.
UI Objects, into specific. Cells. Of that grid and it's, honestly one of the most commonly, used layout. Containers, in zamel, now. Inside, the grid the, first thing that I have is, a login. Button and you see it has the name space WGT, so if I scroll up here we'll, see the. Name space W, is, Microsoft, toolkit graph controls so that is where that control, is housed and then. If I look, a little bit further down here we. Have a text, block which you already saw here, earlier and then we have an items control and an items control is just a way of listing. Or. Listing. Items on. The screen so a list, box is a type of items control, you know there are multiple ways of listing multiple, things one after another on. The screen now, how you control, what shows up and how it shows up is with this item template, and the, item template in this case is, going to show the, display name of the, person object, okay. This. Is all kind of the types of things that you'll see covered in the developer, documentation for, getting started but I just want to give you some context, here for what, what. We're actually looking at. Alright. So I'm getting ready now to run, this application so, I'm gonna run it here. Let's. Go ahead and make sure everything compiles, fine, and. Sing. Your compiled song sometimes it's good to have, a little compiled song that you saying well things are actually working and. The. Application, opened up over there so let me pull it in alright. So now here's our application you, see this little bar at the top is something, that only shows up when you're running the. Application under the visual studio debugger and it has a bunch of functionality, for making. It easier for you to visually, debug parts of the application, so I am going to click sign in here. Alright. So you can sign in to the Microsoft, graph I'm, gonna hit Windows, V I want to see it actually opened up over here this time so, here, is the. Clipboard, history so I'm going to choose Meghan. And. I'm, gonna type in the password. Alright. And. Any, second now there you go you see Meghan, Bowen up here on the top and now that what this is going to do now is I can start typing names now think about when, you're building. Something like an email application, where has. Autocomplete of, names and how much work is involved in doing something like that you, know integrating with Active Directory or, integrating, with Exchange anything well if you use the Microsoft graph it's super simple to, to. Get to that data through these controls, so I can say I can, start typing a name like T and there's, a distribution, group tailspin toys I can say, L. Li. I can, do. Isaiah. There. We are and you, see here, we are we have this automatically, styled, because this is part of the control, that, the Microsoft, graph toolkit, provided, you. Know and then we have the items, control down here at the bottom that lists, all of the items, that, are that I have added in this because of that binding statement that we saw on zamel that second part that binding statement isn't necessary, but I think it's good because it shows you some some. Of the interaction, between this. Control, that we got from the toolkit and the rest of the sam'l UI, system so, really.
Simple Way to build, kind, of like your first hello world application and, the, reason I picked this example, is because this is the kind of stuff that business. Application, developers, have to do all the time and it's usually a lot of work and if you can leverage the. Work of third parties, you know whether there be Microsoft, through, toolkits, which, have community, contributions. Or actual third parties, who. Are building, controls and toolkits and everything for these languages you'll save yourself a ton of time, so, once you get past the hello world stage you definitely want to be leveraging the work of others so you don't have to rebuild everything from scratch each time all. Right I'll close this application. And. That's it for the first part of the demo we'll take a look here in, just a second with, some of the other types, of, applications. That you can build. So. We have some great tutorials that, will help you with building Windows forms applications. Windows. Forms applications, are going to be just kind of drag and drop on the UI so. I can say it's a file new project, and. I'm. Gonna say Windows. Forms. I think that's what's gonna come up it's been a while since I created one, to. Do to do up. The uwp that's a problem so, if I go under. Desktop. Windows. Forms apt on that framework dotnet courts at. We're, gonna have some more templates here coming, soon for dotnet. 5 but. I can build a windows forms application for, dotnet core, which is the cross-platform. Version. Of, of. The.net. Framework so it's a kind of a subset of the.net framework but it also works on Mac and Linux and other operating systems. And. Then we have the full dotnet framework which, is the Donette, framework that we have had you know since the, early 2000, around. 1999. Is when I started messing with alphas and stuff the company I was working with at the time so. You know it's it's at 20 21 years old or so at, this point in time so we have had some changes so if you want to build something new today in, a windows forms application I, would suggest that you pick net core because, that is the the newest, version, it has a really, great performance and also, is going to be the easiest for you to move to dotnet 5 should you decide to do so Don, net framework version is. Really kind of kept around because one, it still works and it works perfectly fine but. It's also there for backwards compatibility for.
People Who are building those applications, so, if I choose a dotnet core application, and, I hit next and yeah. Windows forms happen it's fine, I'm. Gonna have this in a new solution and. It's. Gonna create that for me, and. Then you get standard. Kind. Of dotnet, stuff where you have individual, forms that, you can use and. You can you. Know use the design surfaces for those forms and be able to build applications, using drag-and-drop features, and. Be. Able to again, leverage a more visual, approach to, the. Design work. I'd. Also like to show you here the WPF, approach, for building applications so I can look at file, new. Project again. And, I'm. Gonna say. Presentation. So. If I look WPF, FF framework WPF, app dotnet, core same, thing if, you can build them and dotnet court today that's the approach I'd recommend, I'm, gonna do a straight-up dotnet framework one here today I hit. Next and I'm. Not gonna you know provide any real detail to this Apple but let me just go through the process of creating this for you and you'll see this is very similar, to what we did with the uwp so. Instead, of the. Base class that we had before we. Have a window, class because this is designed. More from the ground up to create straight-up. Application. Windows, whereas ewp is was. Designed you, know at first for, full screen applications, and then those became, windowed afterwards, so, there's a little bit of difference there in the sam'l but everything else, you. Know besides the little differences, are is gonna be very familiar with you to. You so if you learn how to build you WP applications. You're, gonna have the basics of building, zamel, applications, using. WPF, down, because, it's the language is very very, similar the markup is very very similar and of course if you build you WP applications, today the, you know you WP, zamel is what moves into wind UI which. Can be used by WPF, applications, in the future so again, that's really kind of where I would invest, your time there today now, I've. Already gone through the process of building a sam'l application, I'm not gonna spend, your time there doing that but, what I do want to do is get out of Visual Studio here, and do, something I think a little fun so. I'm gonna open up terminal, and. So. Here is the Microsoft. Windows terminal, if, you don't have this yet I highly recommend that you get it it's available free, in the Microsoft, Store it's, an open source and available on github and. You can see you can have tabs you can have multiple different. Different. Shells available to you including, like. I said wsl for doing stuff for Linux, for example right. So here. Is wsl if I can do. Mount. See. Demos. And. You see here is the the folder, that I've been doing demos with on the PC so it says it's full in a full. Integration with the Windows operating system, and access to all the files but. Anyway so if I get back over here to the command prompt what I want to do is I want to create a new dotnet, application. From, the command line so first of all I have, the dotnet SDK, installed, for. Dotnet v one. Of the the, latest previews that we have you, can see here if I do that's version. It's, preview, 3 okay, now, if I want to create any of the types of dotnet, applications, from the command line I can, do everything that I did in Visual Studio right, from here so I don't say dotnet. New WPF. And I can also, do dotnet, new Windows forms in this case I'm going to do Dutton a new console, because I want to show you one of the other types of applications you can build on Windows and the, output folder is, gonna say hello world okay. And so, this is creating, using the.net template. For console, application, a hello, world app so, if I go to hello world and. Look. There there, is my program dot CS and I. Can use notepad if I wanted to and say program, dot CS. Annex. A hello world, from.
Net. 5 yay. Save. That and. If. I type dotnet run here. You'll. See there is the output on the command line now. Just like you can from. Visual studio and kind of the default behavior from visual studio I can compile. And package this application, so it runs standalone, and I don't have to run it using the.net run, command, and that'll, start up a lot faster than what you just saw here and it's also becomes, something. That you could deploy to other pcs, right. Ok. So that was super, fun and of. Course I can run this from WSL. As well, I am, run this on the Linux machines running on Mac or whatever I would like there. So. Let, me just go back to the slides for a second. There. We are. So. I you, know to kind of recap some of the things I mentioned here today so native, applications. I still think are the best way to tap. Native. Features, of the operating, system it's, certainly again if you want to build web applications or, pwace, or poor. To any other kind of portable applications, if that is appropriate, for what you're trying to do then that's awesome I'm not trying to talk you out of that but, I want you to know that you do have the power of native applications, on Windows should, your application, or need that or should you be more comfortable in that kind of environment we. Have free tooling so you can use Visual. Studio for, free you can use github, for free use, all the, all. These different tools here free, for individual, developers, for, open-source development, for small teams etc and really. We have choice, in applications, I showed you you. Can build, ewp. Applications, but we're not trying to force you to build a uwp application, you, can build, WPF. Applications. And those WPF, applications, you can build on dotnet, core the upcoming done f5 or on the.net. Framework which, we've we've had around forever again. I recommend if you're starting today, and you want to do this and today, is, what. I say it's May, May. 13th, of, 2020, I recommend, that you start by using dotnet, core as. The. The. The kind of mature fully. Functional, version of. The.net you. Know what kind of ecosystem to use there today and and. When you're looking a little bit later to, kind.