From the course: Microsoft XAML: 3 Type Converters and Resources

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Data and templates in resources

Data and templates in resources

From the course: Microsoft XAML: 3 Type Converters and Resources

Start my 1-month free trial

Data and templates in resources

- [Instructor] Another comment item you'll find in your resources section, is Data. Especially when you're working with the model–view–view-model pattern. And you'll also often find data templates in there. Alternate UI that you use to render the data as it's shown in the data binding. In this example, I'll use this model class here in this trees.cs file. I have a class called Tree that has two properties, TreeName, and MaxHeight, and then I have a class up here, which is a type ObservableCollection of Tree. And you can see that I'm creating five trees and adding it to the collection. Now I'll go over to the DataWindow, and in my Resources section, I will add an instance of that tree collection. And I'll do that by bringing my namespace into scope here, and then saying Models go in Tree, and then giving it a key. So at this point, it'll instantiate that ObservableCollection. Now the next thing to do is go to my list box, and tell it to use that as the data source. So the first thing I…

Contents