This project need images and model classes. They are used later in this chapter. This video shows how to add assets to a project.
- I'll use some images and classes that contain some data later in this chapter, so I'll need to add those to my project. I'll add these assets in a couple of ways to show you different ways you can add items to WPF projects. The assets I'm looking for are here in the Exercise Files folder, in this Images folder, and this Model folder. Let's start by adding these models, these two C Sharp classes. I could just drag those over or put them in the root of my project, that works for small projects, but it makes for an organizational mess once you start getting work from the bigger projects, so it's good to put folders in your project, just like you put folders in your File Explorer.
I'll right click here and choose Add a folder. There's my folder, and now to add the models, there's a couple of approaches I can take. I'll copy this path, right-click on the Models folder, choose to Add Existing Items, and then I'll paste in the path here. Once I get to that path, I can then shift-click on these files to add multiple files to my project.
For the next demonstration, I'll look at adding images. You see I have this MapPin.png file. I'd like to put that in an images folder, so I can create an images folder, just like I created the Models folder... Like that, and then instead of right-clicking on it and choosing Add Existing Items, I can also drag it from the File Explorer into Visual Studio, and that adds that file to the folder and marks it as a resource.
Now, let's take a look at the Stops folder. There are seven pictures in here. There's a couple of ways I could add these. One way I can add them is to pick up the Stops folder and drop it in the Images folder, like this. This is nice because it creates the folder for me, but it didn't work quite the way you expect it to. I quitted the Stops folder and you'll see here that there's no files in there. Now they're here, but they didn't automatically get added, so I can do a couple of things.
I can go back over here and drag them over, but they're actually in this folder, they're just not in Visual Studio, and you see that by going here and clicking on Show All Files. See those files there and they have these little ghost icon. That means there on the physical hard drive in the Stops folder, but they haven't been added to the project, so what I need to do is shift-click to select them and then right-click and choose Include in Project, and now they go from having little ghost icon to having the image icon.
The other way I could have handled this, I'll shift-click and delete,... Is I could have created the Stops folder manually and then I could just pick these files up and drag the whole item, so I shift-click to select all the files in File Explorer, then drag them over to the Stops folder. And that way they're automatically added, I don't have to go and Show All Files and then Include in Project. I'll compile the project to make sure it builds okay... I have no build errors, now I'm ready to move on to the next step, which means I'm creating the Details UI.
- 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.