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.

Styles in resources

Styles in resources

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

Start my 1-month free trial

Styles in resources

- [Narrator] Now we'll look at how to use some common items you find in Resource sections. And I'll start with styles. Styles are we have determining and setting a number of common properties that you want to apply to lots of elements. In this example, I've decided that I have a style that I want to apply to some of my TextBlocks. So, in my Windows Resource section, I create a style. I'm instantiating the style and then I have to create a key, because it's in a Resource Dictionary. So I do that, it's called "BigAndBold." And then I have to specify what the target type is, so it knows which one to apply it to. In this case, it's a TextBlock. And then I have these setters. There's a setter for setting the text size to 24, and the font-weight bold. Now I can come down here to this TextBlock, this second TextBlock here, and set the style to a static resource, named "BigAndBold." Then all of the setter values in that style are applied to this TextBlock. And if I take the same style, and…

Contents