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.

Explore the concept of attached properties

Explore the concept of attached properties

From the course: Microsoft XAML: 2 Content and Properties

Start my 1-month free trial

Explore the concept of attached properties

- [Instructor] Attached properties are another innovation that came from the WPF team and continues in the other XAML frameworks. One way to think of an attached property is that it's a global property. It's defined in one type, but is settable in other WPF types. I'll show some examples to clarify the concept. In this first example, I have a button element in my XAML. Each property shown here is a dependency property defined in the button class or one of it's base classes. There's no problem using them, they'll work as expected because they are part of the button object members. In this second example, I tried to use properties defined on another class. In this case, the window class. Since these properties are not part of the button object object model, Visual Studio shows a blue warning squiggle. If I tried to run the application, I'll get an error. This makes sense doesn't it? I shouldn't be able to use the properties. The button doesn't know what to do with them. Here's an…

Contents