Class VisualTreeExtensions
Provides useful extensions for working with the visual tree.
Inheritance
Inherited Members
Namespace: System.Windows.Controls.Primitives
Assembly: OpenSilver.dll
Syntax
public static class VisualTreeExtensions
Remarks
Since many of these extension methods are declared on types like DependencyObject high up in the class hierarchy, we've placed them in the Primitives namespace which is less likely to be imported for normal scenarios.
Methods
| Improve this Doc View SourceGetBoundsRelativeTo(FrameworkElement, UIElement)
Get the bounds of an element relative to another element.
Declaration
public static Rect? GetBoundsRelativeTo(this FrameworkElement element, UIElement otherElement)
Parameters
Type | Name | Description |
---|---|---|
FrameworkElement | element | The element. |
UIElement | otherElement | The element relative to the other element. |
Returns
Type | Description |
---|---|
System.Nullable<Rect> | The bounds of the element relative to another element, or null if the elements are not related. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
GetVisualAncestors(DependencyObject)
Get the visual tree ancestors of an element.
Declaration
public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree ancestors of the element. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualAncestorsAndSelf(DependencyObject)
Get the visual tree ancestors of an element and the element itself.
Declaration
public static IEnumerable<DependencyObject> GetVisualAncestorsAndSelf(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree ancestors of an element and the element itself. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualChildren(DependencyObject)
Get the visual tree children of an element.
Declaration
public static IEnumerable<DependencyObject> GetVisualChildren(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree children of an element. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualChildrenAndSelf(DependencyObject)
Get the visual tree children of an element and the element itself.
Declaration
public static IEnumerable<DependencyObject> GetVisualChildrenAndSelf(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree children of an element and the element itself. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualDescendants(DependencyObject)
Get the visual tree descendants of an element.
Declaration
public static IEnumerable<DependencyObject> GetVisualDescendants(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree descendants of an element. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualDescendantsAndSelf(DependencyObject)
Get the visual tree descendants of an element and the element itself.
Declaration
public static IEnumerable<DependencyObject> GetVisualDescendantsAndSelf(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree descendants of an element and the element itself. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualSiblings(DependencyObject)
Get the visual tree siblings of an element.
Declaration
public static IEnumerable<DependencyObject> GetVisualSiblings(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree siblings of an element. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
GetVisualSiblingsAndSelf(DependencyObject)
Get the visual tree siblings of an element and the element itself.
Declaration
public static IEnumerable<DependencyObject> GetVisualSiblingsAndSelf(this DependencyObject element)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | element | The element. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<DependencyObject> | The visual tree siblings of an element and the element itself. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
InvokeOnLayoutUpdated(FrameworkElement, Action)
Perform an action when the element's LayoutUpdated event fires.
Declaration
public static void InvokeOnLayoutUpdated(this FrameworkElement element, Action action)
Parameters
Type | Name | Description |
---|---|---|
FrameworkElement | element | The element. |
System.Action | action | The action to perform. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|