From the course: Microsoft XAML: 2 Content and Properties
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Content as a dictionary in code
From the course: Microsoft XAML: 2 Content and Properties
Content as a dictionary in code
- [Instructor] Adding items to a resource dictionary is straightforward in code. If you've worked with any other dictionaries in the past, it's very similar to how you work with those. I'll go to the resources property on the window class (keyboard clicking) and it has a method called add. When I add an item, I need to provide a key of type object and the value that I wanna store in their resource dictionary of type object. I'll use strings as the key. (keyboard clicking) As I said, the code is straightforward. The key's a string. The value's instance of a solid color brush is being added the resource dictionary that's part of this resource's property. Copy this line of code, paste it in and add another brush. (keyboard clicking) Since it's typed as object, I can put anything I want in this dictionary. Here's an example of putting a string in the dictionary. (keyboard clicking) I'll use a string for the key (keyboard clicking) and a string for the value. At this point, I've added…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
What does content mean in XAML?3m 41s
-
(Locked)
Use children elements as content7m 5s
-
(Locked)
Install the dotPeek utility1m 16s
-
How each element defines a content property5m 28s
-
(Locked)
Content as an object in XAML6m 32s
-
(Locked)
Content as an object in code5m 33s
-
(Locked)
Visual content in panels4m 59s
-
(Locked)
Content as a list in XAML3m 53s
-
(Locked)
Content as a list in code3m 6s
-
(Locked)
Content as a dictionary in XAML4m 53s
-
(Locked)
Content as a dictionary in code1m 25s
-
(Locked)
-
-