Click or drag to resize

RelayedEventAttribute Class

Attribute to mark one property to relay the property changed events of another property from the governing class. If you call OnPropertyChanged(String) for a property of the governing class, the property change event will also be raised for the relayed property.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    TomsToolbox.WpfRelayedEventAttribute

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)]
public sealed class RelayedEventAttribute : Attribute

The RelayedEventAttribute type exposes the following members.

Constructors
 NameDescription
Public methodRelayedEventAttribute(Type) Initializes a new instance of the RelayedEventAttribute class.
Public methodRelayedEventAttribute(Type, String) Initializes a new instance of the RelayedEventAttribute class.
Top
Properties
 NameDescription
Public propertySourceName Gets the name of the source property, or null if the name is the same as the target property.
Public propertySourceType Gets the type of the source for the events.
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
{
    Y _governingObject;

    public X(Y governingObject)
    {
        _governingObject = governingObject;
        RelayEventsOf(_governingObject);
    }

    [RelayedEvent(typeof(Y))]
    string Value { get { return _governingObject.Value } }

    void ChageSomething()
    {
        _governingObject.Value = "new Value";
    }
}
Changing 'Y.Value' will also raise the PropertyChanged event for the "X.Value" property.
See Also