Click or drag to resize

PropertyDependencyAttribute Class

Attribute to mark one property as dependent on another property. If you call OnPropertyChanged(String) for one property, the property change event will also be raised for all dependent properties.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    TomsToolbox.WpfPropertyDependencyAttribute

Namespace: TomsToolbox.Wpf
Assembly: TomsToolbox.Wpf (in TomsToolbox.Wpf.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
[AttributeUsageAttribute(AttributeTargets.Property)]
[CLSCompliantAttribute(false)]
public sealed class PropertyDependencyAttribute : Attribute

The PropertyDependencyAttribute type exposes the following members.

Constructors
 NameDescription
Public methodPropertyDependencyAttribute Initializes a new instance of the PropertyDependencyAttribute class.
Top
Properties
 NameDescription
Public propertyPropertyNames Gets the names of the properties that the attributed property depends on.
Top
Methods
 NameDescription
Public methodStatic memberCreateDependencyMapping Creates the dependency mapping from the attributes of the properties of the specified type.
Public methodStatic memberGetInvalidDependencies Gets a list of invalid dependency definitions in the entry types assembly and all referenced assemblies.
Top
Extension Methods
 NameDescription
Public Extension MethodSafeCastT Performs a cast from object to T, avoiding possible null violations if T is a value type.
(Defined by ObjectExtensions)
Top
Example
C#
class X : ObservableObject
{
    string Value { get { ... } }

    [PropertyDependency("Value")]
    int ValueLength { get { ... } }

    void ChangeSomething()
    {
        OnPropertyChanged("Value");
    }
}
Calling 'OnPropertyChanged("Value")' will raise the PropertyChanged event for the "Value" property as well as for the dependent "ValueLength" property.
See Also