Files
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

11 KiB
Raw Permalink Blame History

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
Framework Property Metadata 03/30/2017
metadata [WPF], framework properties
framework property metadata [WPF]
9962f380-b885-4b61-a62e-457397083fea

Framework Property Metadata

Framework property metadata options are reported for the properties of object elements considered to be at the WPF framework level in the WPF presentation APIs and executables. Framework property metadata is queried by these systems to determine feature-specific characteristics of particular element properties.

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. You should also have read Dependency Property Metadata.

What Is Communicated by Framework Property Metadata

Framework property metadata can be divided into the following categories:

Reading FrameworkPropertyMetadata

Each of the properties linked above are the specific properties that the xref:System.Windows.FrameworkPropertyMetadata adds to its immediate base class xref:System.Windows.UIPropertyMetadata. Each of these properties will be false by default. A metadata request for a property where knowing the value of these properties is important should attempt to cast the returned metadata to xref:System.Windows.FrameworkPropertyMetadata, and then check the values of the individual properties as needed.

Specifying Metadata

When you create a new metadata instance for purposes of applying metadata to a new dependency property registration, you have the choice of which metadata class to use: the base xref:System.Windows.PropertyMetadata or some derived class such as xref:System.Windows.FrameworkPropertyMetadata. In general, you should use xref:System.Windows.FrameworkPropertyMetadata, particularly if your property has any interaction with property system and WPF functions such as layout and data binding. Another option for more sophisticated scenarios is to derive from xref:System.Windows.FrameworkPropertyMetadata to create your own metadata reporting class with extra information carried in its members. Or you might use xref:System.Windows.PropertyMetadata or xref:System.Windows.UIPropertyMetadata to communicate the degree of support for features of your implementation.

For existing properties (xref:System.Windows.DependencyProperty.AddOwner%2A or xref:System.Windows.DependencyProperty.OverrideMetadata%2A call), you should always override with the metadata type used by the original registration.

If you are creating a xref:System.Windows.FrameworkPropertyMetadata instance, there are two ways to populate that metadata with values for the specific properties that communicate the framework property characteristics:

  1. Use the xref:System.Windows.FrameworkPropertyMetadata constructor signature that allows a flags parameter. This parameter should be filled with all desired combined values of the xref:System.Windows.FrameworkPropertyMetadataOptions enumeration flags.

  2. Use one of the signatures without a flags parameter, and then set each reporting Boolean property on xref:System.Windows.FrameworkPropertyMetadata to true for each desired characteristic change. If you do this, you must set these properties before any elements with this dependency property are constructed; the Boolean properties are read-write in order to allow this behavior of avoiding the flags parameter and still populate the metadata, but the metadata must become effectively sealed before property use. Thus, attempting to set the properties after metadata is requested will be an invalid operation.

Framework Property Metadata Merge Behavior

When you override framework property metadata, the different metadata characteristics are either merged or replaced.

This behavior is implemented by xref:System.Windows.FrameworkPropertyMetadata.Merge%2A, and can be overridden on derived metadata classes.

See also