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

Use resource with the StaticResource markup extensions

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

Start my 1-month free trial

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…

Contents