From the course: Microsoft XAML: 3 Type Converters and Resources
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Use resource with the StaticResource markup extensions
From the course: Microsoft XAML: 3 Type Converters and Resources
Use resource with the StaticResource markup extensions
- [Instructor] I've defined my resources in a resources section. Here's where I have the Windows.Resources level and I have two solid color brushes in here. I'm ready to use those. These are identified by a key, so I need some sort of tool in XAML that can go into my resources section and grab one of those items and pull it into my XAML. And the tool for doing that is called a static resource markup extension. Static resource means look up a resource in a static fashion. Here's what I mean. I'll go down to this fill property of this rectangle. Type in the open curly brace, which is the way we tell XAML that we're using a markup extension. And I use static resource, and the value that I need to provide here is the key. I've got two choices: main brush and accent brush. And Visual Studio will give me some help when I hit the spacebar, you'll see that it shows me two items, AccentBrush and Mainbrush and also let's me do a more specific syntax where I can say ResourceKey equal MainBrush…
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
-
-
-
-
Types of resources6m 31s
-
XAML resources and ResourceDictionaries4m 4s
-
The Resources property2m 44s
-
Use resource with the StaticResource markup extensions3m 46s
-
Styles in resources1m 23s
-
Colors in resources1m 29s
-
Data and templates in resources3m 3s
-
Explore the resource hierarchy2m 51s
-
Create Resources with the Properties window5m 54s
-
A quick look at merged resources5m 24s
-
Use the Pack URI to locate resource files2m 39s
-
Load a resource file for dynamic application UI2m 6s
-
-