Skip to Content
Professional Visual Basic 2012 and .NET 4.5 Programming
book

Professional Visual Basic 2012 and .NET 4.5 Programming

by Bill Sheldon, Billy Hollis, Rob Windsor, David McCarter, Gastón Hillar, Todd Herman
January 2013
Intermediate to advanced
912 pages
26h 58m
English
Wrox
Content preview from Professional Visual Basic 2012 and .NET 4.5 Programming

Resources in XAML

Efficient developers like to create capabilities once, and then reuse them as necessary. The usual object-oriented techniques for reuse are available in XAML, because the .NET Framework provides them. But XAML also includes a special capability to create constructs for reuse, in the form of XAML resources.

If you are an experienced .NET developer, the term resources may already be familiar to you. .NET supports resources for capabilities such as localization. Resource files in .NET normally have the extension .resx. However, that's a completely separate concept from XAML resources. This section has nothing to do with .resx files, localization, or any of the subjects you might normally associate with .NET resources.

In XAML, the term resources has a different meaning. XAML resources are objects that are declared once and then available for use in several places. Resources are usually declared in XAML, but as with all other XAML objects, they can also be created in code. In this chapter, you will work exclusively with XAML resources created in XAML.

The Resources Property

XAML elements have a property named Resources, and it holds a dictionary of objects called a ResourceDictionary. Any type of object can go in the dictionary.

Because it's a dictionary, every item in a ResourceDictionary needs a key. This key is normally supplied with another helper capability in the x: namespace, which is the x:Key attribute.

To see the syntax, suppose our UserControl in the original ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Visual Basic 2012 Programmer's Reference

Visual Basic 2012 Programmer's Reference

Rod Stephens

Publisher Resources

ISBN: 9781118332139Purchase book