Extension Methods
Various extension methods are provided for several common .NET types.
Important
The ActiproSoftware.Windows.Extensions namespace must be imported for the extensions described below to be available.
Tip
The Core Library defines many additional Extension Methods for common types that are not associated with a UI framework.
DependencyObject Extensions
The DependencyObjectExtensions type contains extension methods for the DependencyObject type. Some of the most frequently used extension methods are highlighted below. Refer to the API documentation for additional methods.
Important
The WPF platform defines both Visual and Visual3D as visual objects, but DependencyObject (which is not explicitly a visual) is the only common base class. Any extension methods that interact with the visual tree must accept a DependencyObject but will ignore the object if it is not a Visual or Visual3D instance. For example, calling GetVisualParent on an object that is not a Visual or Visual3D instance will always return null.
| Member | Description |
|---|---|
| FindAncestorOfType<T> | Finds the first ancestor of the given type in the visual tree. |
| FindDescendantOfType<T> | Finds the first descendant of the given type in the visual tree. |
| FindLogicalAncestorOfType<T> | Finds the first ancestor of the given type in the logical tree. |
| FindLogicalDescendantOfType<T> | Finds the first descendant of the given type in the logical tree. |
| GetVisualAncestors | Enumerates the ancestors of a visual in the visual tree and can be easily combined with LINQ queries. |
| GetVisualDescendants | Enumerates the descendants of a visual in the visual tree and can be easily combined with LINQ queries. |
| GetLogicalAncestors | Enumerates the ancestors of an object in the logical tree and can be easily combined with LINQ queries. |
| GetLogicalDescendants | Enumerates the descendants of an object in the logical tree and can be easily combined with LINQ queries. |