Beruflich Dokumente
Kultur Dokumente
Prerequisites
This topic assumes that you understand dependency properties from the perspective of a consumer of existing dependency properties on Windows Presentation Foundation (WPF) classes, and have read the Dependency Properties Overview. To follow the examples in this topic, you should also understand XAML and know how to write WPF applications.
12/19/13
Note that the usage is somewhat similar to a static property; you always reference the type DockPanel that owns and registers the attached property, rather than referring to any instance specified by name. Also, because an attached property in XAML is an attribute that you set in markup, only the set operation has any relevance. You cannot directly get a property in XAML, although there are some indirect mechanisms for comparing values, such as triggers in styles (for details, see Styling and Templating).
msdn.microsoft.com/en-us/library/ms749011(d=printer,v=vs.110).aspx
2/6
12/19/13
msdn.microsoft.com/en-us/library/ms749011(d=printer,v=vs.110).aspx
3/6
12/19/13
child elements to layout-controlling elements are able to express layout requirements to their layout parent elements individually, each setting a property value that the parent defined as an attached property. Another scenario for using an attached property is when your class represents a service, and you want classes to be able to integrate the service more transparently. Yet another scenario is to receive Visual Studio 2008 WPF Designer support, such as Properties window editing. For more information, see Control Authoring Overview. As mentioned before, you should register as an attached property if you want to use property value inheritance.
12/19/13
instances.
The value object can be specified as a more specific type in your implementation. For example, the SetDock method types it as Dock, because the value can only be set to that enumeration. Remember that the value for this method is the input coming from the XAML loader when it encounters your attached property in an attached property usage in markup. That input is the value specified as a XAML attribute value in markup. Therefore there must be type conversion, value serializer, or markup extension support for the type you use, such that the appropriate type can be created from the attribute value (which is ultimately just a string). The following example shows the dependency property registration (using the RegisterAttached method), as well as the GetPropertyName and SetPropertyName accessors. In the example, the attached property name is I s B u b b l e S o u r c e . Therefore, the accessors must be named G e t I s B u b b l e S o u r c eand S e t I s B u b b l e S o u r c e . C#
msdn.microsoft.com/en-us/library/ms749011(d=printer,v=vs.110).aspx
5/6
12/19/13
See Also
Tasks
How to: Register an Attached Property
Reference Concepts
DependencyProperty Dependency Properties Overview Custom Dependency Properties XAML Overview (WPF)
msdn.microsoft.com/en-us/library/ms749011(d=printer,v=vs.110).aspx
6/6