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.DesktopRelayedEventAttribute

Namespace:  TomsToolbox.Desktop
Assembly:  TomsToolbox.Desktop (in TomsToolbox.Desktop.dll) Version: 1.0.69.0
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.

[CanBeNull]

Public propertySourceType
Gets the type of the source for the events.

[NotNull]

Top
Extension Methods
  NameDescription
Public Extension MethodSafeCastT
Performs a cast from object to T, avoiding possible null violations if T is a value type.

[CanBeNull]

(Defined by ObjectExtensions.)
Top
Examples
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