This video tours the parts of a standard WPF project. The journey includes a look at the XAML files, the associated code behind file and the project settings.
- [Narrator] I created a TailorMadeTours project (mumbles) in this chapter; it's WPF dekstop application. In another movie in this chapter, I looked at the References list; you have to have PresentationCore, PresentationFramework and WindowsBase reference in the project. In this video, I'll take a look at the other standard items you find in a WPF project. (mumbles) specific items I'm talking about here are these xaml files; App.xaml, and MainWindows.xaml; MainWindows.xaml is the window that is shown when you start this application.
Double click on this file in Solution Explorer and it takes me to the Visual Studio WPF Designer. The top half of the screen contains a Visual Designer for dragging and dropping controls and manipulating them with my mouse and the bottom half of the screen contains a Text Editor for me to write xml or xaml. It is an associated file that's also considered to be closely associated with this xaml file; it is this C# file here; expand this node and you'll see it; has the same name as a xaml file with the .cs extension on it.
When I double click on this node in Solution Explorer, it takes me to the C# editor. Now, I can switch back, of course, by going back and forth (mumbles) my tabs or by double clicking on the items in Solution Explorer again; So, this is my main window; App.xaml is where you define application-wide event handlers and application-wide resources. Open this file and you'll see that it doesn't have a Visual Designer, it just has the xaml editor. Here's why I (mumbles) define Application level Resources and here on line five, you can see; is where I specify which window is a starting point of; in a real-world application, you might have more than one window and one of them has been designated as a Startup object, so you that here with this property called StartupUri.
There's also an affiliated C# file here and as I said this is where define things like application-level event handlers like on the application startup or application shutdown, you write those handlers in here. Now, let's go look in Properties. There's really only a couple things (mumbles) interest here for WPF developers and on this first section in Application, first one I want to look at is the Target Framework; I'm in Visual Studio 2015 and I want to use the template; it decided to use .NET 4.6.1; there are other versions of the Framework available that I can use for my project.
WPF goes back to a number of these, but, we'll use the most recent one here. The other important thing is what your Output Type is, so there's three choices here: Class Library, Console Application and Windows Application. When you choose Windows Application, that means this common language Runtime when it runs this, we'll run it in a windowed environment and that's, of course, important for a Windows desktop application.
- Recognize the pluses of choosing Windows Presentation Foundations over other Microsoft UI frameworks.
- Evaluate the different options available with Windows Presentation Foundation project types.
- Devise a Windows Presentation Foundation project in Visual Studio.
- Break down the assemblies and parts of Windows Presentation Foundations.
- Use XAML editor and editor settings.
- Selecting data binding to present data.
- Compiling interaction code for an application.
- Use control templates, 3D parts, and effects in Windows Presentation Foundations.