When you look at the metadata for a dependency property that is storing its metadata as an instance of FrameworkPropertyMetadata, you’ll see a series of boolean properties.

As a convenience, when constructing an instance of FrameworkPropertyMetadata, you don’t have to pass all of these boolean values into the constructor individually. Instead, the constructor accepts a flags parameter that is a logical OR of a series of enumeration values. The individual enumeration values come from the FrameworkPropertyMetadataOptions enum.

You can read a dependency property’s metadata by using the DependencyProperty.GetMetadata method.

For example, assume that we have a Dog class with a BirthYear dependency property and that the class has exposed BirthYearProperty as a public member. We can retrieve the property’s metadata as follows:

You should normally avoid calling any virtual methods in a C# class constructor. Your constructor might get called during construction of a derived class, before the derived class has finished initializing everything that it needs to initialize. If the derived class also overrides the virtual method that you’re calling, that method could end up getting called before the derived class has finished initializing everything (in its constructor).

You might wonder whether your properties have to be WPF dependency properties in order to set their values from XAML. It turns out that the properties on the custom class do not have to be dependency properties in order to be set from XAML. They can be standard CLR properties.