Class Behavior
Encapsulates state information and zero or more ICommands into an attachable object.
Implements
Inherited Members
Namespace: System.Windows.Interactivity
Assembly: OpenSilver.Interactivity.dll
Syntax
public abstract class Behavior : DependencyObject, IAttachedObject
Remarks
This is an infrastructure class. Behavior authors should derive from Behavior<T> instead of from this class.
Properties
| Improve this Doc View SourceAssociatedObject
Gets the object to which this behavior is attached.
Declaration
protected DependencyObject AssociatedObject { get; }
Property Value
Type | Description |
---|---|
DependencyObject |
AssociatedType
The type to which this behavior can be attached.
Declaration
protected Type AssociatedType { get; }
Property Value
Type | Description |
---|---|
System.Type |
Methods
| Improve this Doc View SourceAttach(DependencyObject)
Attaches to the specified object.
Declaration
public void Attach(DependencyObject dependencyObject)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | dependencyObject | The object to attach to. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The Behavior is already hosted on a different element. |
System.InvalidOperationException | dependencyObject does not satisfy the Behavior type constraint. |
Detach()
Detaches this instance from its associated object.
Declaration
public void Detach()
OnAttached()
Called after the behavior is attached to an AssociatedObject.
Declaration
protected virtual void OnAttached()
Remarks
Override this to hook up functionality to the AssociatedObject.
OnDetaching()
Called when the behavior is being detached from its AssociatedObject, but before it has actually occurred.
Declaration
protected virtual void OnDetaching()
Remarks
Override this to unhook functionality from the AssociatedObject.
Explicit Interface Implementations
| Improve this Doc View SourceIAttachedObject.AssociatedObject
Gets the associated object.
Declaration
DependencyObject IAttachedObject.AssociatedObject { get; }
Returns
Type | Description |
---|---|
DependencyObject | The associated object. |