Show / Hide Table of Contents

Class DependencyObjectHelpers

Includes a set of helper functions to create dependency properties.

Inheritance
object
DependencyObjectHelpers
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Helpers
Assembly: MCART.Wpf.Common.dll
Syntax
public static class DependencyObjectHelpers

Methods

| Edit this page View Source

AddOwner<TOwner>(DependencyProperty, object, PropertyChangedCallback?, CoerceValueCallback?)

Shortens the syntax/semantics required to add an owner type to a dependency property.

Declaration
public static void AddOwner<TOwner>(this DependencyProperty property, object defaultValue = null, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null) where TOwner : DependencyObject
Parameters
Type Name Description
DependencyProperty property

Property to add the new owner to.

object defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

Type Parameters
Name Description
TOwner

Owner type to add.

| Edit this page View Source

NewDp2Way<TValue, TOwner>(string, FrameworkPropertyMetadataOptions, TValue, PropertyChangedCallback?, CoerceValueCallback?, ValidateValueCallback?)

Shortens the syntax/semantics required to declare and create a new dependency property that binds 2-way by default, using a FrameworkPropertyMetadata as the dependency property metadata.

Declaration
public static DependencyProperty NewDp2Way<TValue, TOwner>(string name, FrameworkPropertyMetadataOptions flags, TValue defaultValue = default, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null, ValidateValueCallback? validate = null) where TOwner : DependencyObject
Parameters
Type Name Description
string name

Name of the new dependency property.

FrameworkPropertyMetadataOptions flags

Flags to set on the property metadata.

TValue defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

ValidateValueCallback validate

Callback to execute whenever a value need to be validated before assigning the dependency property.

Returns
Type Description
DependencyProperty

A new dependency property.

Type Parameters
Name Description
TValue

Type of value to be stored to and retrieved by the new dependency property.

TOwner

Dependency property owner type.

| Edit this page View Source

NewDp2Way<TValue, TOwner>(string, TValue, PropertyChangedCallback?, CoerceValueCallback?, ValidateValueCallback?)

Shortens the syntax/semantics required to declare and create a new dependency property that binds 2-way by default.

Declaration
public static DependencyProperty NewDp2Way<TValue, TOwner>(string name, TValue defaultValue = default, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null, ValidateValueCallback? validate = null) where TOwner : DependencyObject
Parameters
Type Name Description
string name

Name of the new dependency property.

TValue defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

ValidateValueCallback validate

Callback to execute whenever a value need to be validated before assigning the dependency property.

Returns
Type Description
DependencyProperty

A new dependency property.

Type Parameters
Name Description
TValue

Type of value to be stored to and retrieved by the new dependency property.

TOwner

Dependency property owner type.

| Edit this page View Source

NewDpRo<TValue, TOwner>(string, FrameworkPropertyMetadataOptions, TValue, PropertyChangedCallback?, CoerceValueCallback?, ValidateValueCallback?)

Shortens the syntax/semantics required to declare and create a new read-only dependency property.

Declaration
public static (DependencyPropertyKey, DependencyProperty) NewDpRo<TValue, TOwner>(string name, FrameworkPropertyMetadataOptions flags, TValue defaultValue = default, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null, ValidateValueCallback? validate = null) where TOwner : DependencyObject
Parameters
Type Name Description
string name

Name of the new dependency property.

FrameworkPropertyMetadataOptions flags

Flags to set on the property metadata.

TValue defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

ValidateValueCallback validate

Callback to execute whenever a value need to be validated before assigning the dependency property.

Returns
Type Description
(DependencyPropertyKey, DependencyProperty)

A tuple consisting of a new DependencyPropertyKey and its corresponding DependencyProperty that represents the dependency property.

Type Parameters
Name Description
TValue

Type of value to be stored to and retrieved by the new dependency property.

TOwner

Dependency property owner type.

| Edit this page View Source

NewDpRo<TValue, TOwner>(string, TValue, PropertyChangedCallback?, CoerceValueCallback?, ValidateValueCallback?)

Shortens the syntax/semantics required to declare and create a new read-only dependency property.

Declaration
public static (DependencyPropertyKey, DependencyProperty) NewDpRo<TValue, TOwner>(string name, TValue defaultValue = default, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null, ValidateValueCallback? validate = null) where TOwner : DependencyObject
Parameters
Type Name Description
string name

Name of the new dependency property.

TValue defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

ValidateValueCallback validate

Callback to execute whenever a value need to be validated before assigning the dependency property.

Returns
Type Description
(DependencyPropertyKey, DependencyProperty)

A tuple consisting of a new DependencyPropertyKey and its corresponding DependencyProperty that represents the dependency property.

Type Parameters
Name Description
TValue

Type of value to be stored to and retrieved by the new dependency property.

TOwner

Dependency property owner type.

| Edit this page View Source

NewDp<TValue, TOwner>(string, FrameworkPropertyMetadataOptions, TValue, PropertyChangedCallback?, CoerceValueCallback?, ValidateValueCallback?)

Shortens the syntax/semantics required to declare and create a new dependency property, using a FrameworkPropertyMetadata as the dependency property metadata.

Declaration
public static DependencyProperty NewDp<TValue, TOwner>(string name, FrameworkPropertyMetadataOptions flags, TValue defaultValue = default, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null, ValidateValueCallback? validate = null) where TOwner : DependencyObject
Parameters
Type Name Description
string name

Name of the new dependency property.

FrameworkPropertyMetadataOptions flags

Flags to set on the property metadata.

TValue defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

ValidateValueCallback validate

Callback to execute whenever a value need to be validated before assigning the dependency property.

Returns
Type Description
DependencyProperty

A new dependency property.

Type Parameters
Name Description
TValue

Type of value to be stored to and retrieved by the new dependency property.

TOwner

Dependency property owner type.

| Edit this page View Source

NewDp<TValue, TOwner>(string, TValue, PropertyChangedCallback?, CoerceValueCallback?, ValidateValueCallback?)

Shortens the syntax/semantics required to declare and create a new dependency property.

Declaration
public static DependencyProperty NewDp<TValue, TOwner>(string name, TValue defaultValue = default, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null, ValidateValueCallback? validate = null) where TOwner : DependencyObject
Parameters
Type Name Description
string name

Name of the new dependency property.

TValue defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

ValidateValueCallback validate

Callback to execute whenever a value need to be validated before assigning the dependency property.

Returns
Type Description
DependencyProperty

A new dependency property.

Type Parameters
Name Description
TValue

Type of value to be stored to and retrieved by the new dependency property.

TOwner

Dependency property owner type.

| Edit this page View Source

OverrideMetadata<TOwner>(DependencyProperty, object, PropertyChangedCallback?, CoerceValueCallback?)

Shortens the syntax/semantics required to override the metadata associated with a dependency property.

Declaration
public static void OverrideMetadata<TOwner>(this DependencyProperty property, object defaultValue = null, PropertyChangedCallback? changedValue = null, CoerceValueCallback? coerceValue = null) where TOwner : DependencyObject
Parameters
Type Name Description
DependencyProperty property

Property to add the new owner to.

object defaultValue

Optional. Defines a default value to use for this dependency property.

PropertyChangedCallback changedValue

Callback to execute whenever this dependency property changes its value.

CoerceValueCallback coerceValue

Callback to execute whenever a value needs to be coerced.

Type Parameters
Name Description
TOwner

Owner type to add.

| Edit this page View Source

SetControlStyle<T>()

Shortens the syntax/semantics required to override and set the default style for a custom control.

Declaration
public static void SetControlStyle<T>() where T : FrameworkElement
Type Parameters
Name Description
T

Type of control to set the default style for.

| Edit this page View Source

SetControlStyle<T>(DependencyProperty)

Shortens the syntax/semantics required to override and set the default style for a custom control.

Declaration
public static void SetControlStyle<T>(DependencyProperty styleDp) where T : FrameworkElement
Parameters
Type Name Description
DependencyProperty styleDp

Style property. Must be equal to DefaultStyleKeyProperty.

Type Parameters
Name Description
T

Type of control to set the default style for.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX