Freigeben über


ExtensionMethods Class

Definition

Extension methods for non-VS types. Extensions for VS types should be placed in env\shell\PackageFramework\Current\Shell\UI\Common\ExtensionMethods.cs

This type is forwarded from MS.VS.Shell.xx.dll

public ref class ExtensionMethods abstract sealed
public ref class ExtensionMethods abstract sealed
class ExtensionMethods abstract sealed
public static class ExtensionMethods
type ExtensionMethods = class
Public Module ExtensionMethods
Inheritance
ExtensionMethods

Methods

AcquireWin32Focus(DependencyObject, IntPtr)

Puts the Win32 focus to the HWND of the HwndSource of the DependencyObject provided. If a new HWND other than currently focused one is focused then it returns true, setting the previousFocus parameter to the previously focused HWND and it returns false otherwise.

AddPropertyChangeHandler<T>(T, DependencyProperty, EventHandler, Type)

Adds a handler that is called when property changes on instance

AddPropertyChangeHandler<T>(T, DependencyProperty, EventHandler)

Adds a handler that is called when property changes on instance

CopyTo(Stream, Stream)

Add a simple copy method to Stream

FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Helper method that finds the first ancestor of a given Type in the logical or visual tree.

FindAncestor<TAncestorType>(Visual)

Helper method that finds the first ancestor of a given Type in the logical or visual tree.

FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)

Helper method that finds the first ancestor in the logical or visual tree that is accepted by the ancestor selector function.

FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Helper method that finds the first ancestor of a given Type in the logical or visual tree, or the object itself if it matches in type.

FindAncestorOrSelf<TAncestorType>(Visual)

Helper method that finds the first ancestor of a given Type in the logical or visual tree, or the object itself if it matches in type.

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)

Helper method that finds the first ancestor in the logical or visual tree, or the object itself, that is accepted by the ancestor selector function.

FindCommonAncestor(DependencyObject, DependencyObject)

Finds the common ancestor of obj1 and obj2 using the GetVisualOrLogicalParent as the parent evaluation method.

FindCommonAncestor<T>(T, T, Func<T,T>)

Finds the common ancestor of obj1 and obj2 using the given function to get the parent of each element.

FindDescendant(DependencyObject, Predicate<DependencyObject>)

Helper method that finds the first descendant satisfying predicate.

USE SPARINGLY.

This method walks all the tree until a result is found. Use of this method on large trees or excessively will introduce a performance hit.

FindDescendant<T>(DependencyObject, Predicate<T>)

Helper method that finds the first descendant of type T the visual tree that matches predicate.

USE SPARINGLY.

This method walks all the tree until a result is found. Use of this method on large trees or excessively will introduce a performance hit.

FindDescendant<T>(DependencyObject)

Helper method that finds the first descendant of a given Type in the visual tree.

USE SPARINGLY.

This method walks all the tree until a result is found. Use of this method on large trees or excessively will introduce a performance hit.

FindDescendantReverse<T>(DependencyObject)

Helper method that finds the last descendant of a given Type in the visual tree.

USE SPARINGLY.

This method walks all the tree in reverse order until a result is found. Use of this method on large trees or excessively will introduce a performance hit.

FindDescendants<T>(DependencyObject)

Find all visual descendants of this dependency object of a particular type.

USE SPARINGLY.

This method walks the entire tree. Use of this method on large trees or excessively will introduce a performance hit.

FindDescendantsReverse<T>(DependencyObject)

In reverse order: Find all visual descendants of this dependency object of a particular type.

USE SPARINGLY.

This method walks the entire tree. Use of this method on large trees or excessively will introduce a performance hit.

GetDoubleAttribute(XmlReader, String, Double)

Get a named attribute from the current node in the given XmlReader as a double

GetGuidAttribute(XmlReader, String)

Get a named attribute from the current node in the given XmlReader as a Guid

GetIntAttribute(XmlReader, String, Int32)

Get a named attribute from the current node in the given XmlReader as an int

GetValueIfCreated<T>(Lazy<T>)

Returns the Value of a Lazy<T> if it has been created, or null if it hasn't.

GetVisualOrLogicalParent(DependencyObject)

This uses the visual tree first, then diverts to the logical tree if the visual tree ends. This is necessary for the TabControl, where using either the logical tree or visual tree by themselves is insufficient.

IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>)

Determines if a element is an ancestor of another element.

IsClipped(UIElement)

Checks whether the element's text is clipped by a parent ScrollViewer (the element can still be scrolled to view the clipped text)

IsConnectedToPresentationSource(DependencyObject)

Used to determine if a given DependencyObject is rooted in a PresentationSource. In order to determine screen coordinates from relative coordinates, this element has to be rooted in a PresentationSource. It can also tell us whether something is presently in the visual tree or not.

IsCritical(Exception)
IsLogicalAncestorOf(DependencyObject, DependencyObject)

Determines if an element is an ancestor of another element using both the logical and visual trees.

IsNearlyEqual(Double, Double)

Helper method to determine if a double is the same type of non-real or nearly equal to another double.

IsSignificantlyGreaterThan(Double, Double)

Indicates if value1 (this) is significantly greater than value2.

IsSignificantlyLessThan(Double, Double)

Indicates if value1 (this) is significantly less than value2.

IsTextTrimmed(TextBlock)

Returns whether the text of the TextBlock is trimmed Unfortunately the TextBlock control does not have a property to tell when ellipsis are displayed So we have to calculate outselves if the text fits in the text block element

IsTopmost(IntPtr)

Determines if an HWND is a topmost window.

IsTrimmed(UIElement)

Checks whether the control is a TextBlock whose text is trimmed (and ellipses are displayed)

RaiseEvent(CancelEventHandler, Object, CancelEventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(EventHandler, Object, EventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(EventHandler, Object)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(EventHandler<DependencyPropertyChangedEventArgs>, Object, DependencyPropertyChangedEventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(NotifyCollectionChangedEventHandler, Object, NotifyCollectionChangedEventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(PropertyChangedEventHandler, Object, PropertyChangedEventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(PropertyChangedEventHandler, Object, String)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(PropertyChangingEventHandler, Object, PropertyChangingEventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent(PropertyChangingEventHandler, Object, String)

Helper method to perform the null check necessary to raise an event safely.

RaiseEvent<TEventArgs>(EventHandler<TEventArgs>, Object, TEventArgs)

Helper method to perform the null check necessary to raise an event safely.

RaiseEventAsync<T>(Delegate, Object, T)

Helper method to call each target of an async event sequentially, awaiting each until it completes.

RemovePropertyChangeHandler<T>(T, DependencyProperty, EventHandler, Type)

Removes a handler for a dependency property change

RemovePropertyChangeHandler<T>(T, DependencyProperty, EventHandler)

Removes a handler for a dependency property change

ThrowIfNullOrEmpty(String, String)

Add a throw from string to verify that it is not null or empty

ToArgb(Color)

Returns a uint representing the ARGB value of the color

ToColorFromArgb(UInt32)

Returns a Color object from ARGB

ToColorFromRgba(UInt32)

Returns a Color object from RGBA

ToDimensionString(Size)

Returns a string for size, as "{width}x{height}"

ToLowercaseString(Color)

Returns a lowercase string for color. This is equivalent to color.ToString().ToLower(), but it doesn't create extra garbage.

ToLowercaseString(Nullable<Color>)

Returns a lowercase string for color. This is equivalent to color.ToString().ToLower(), but it doesn't create extra garbage.

ToRgba(Color)

Returns a uint representing the RGBA value of the color

TraverseVisualTree<T>(DependencyObject, Action<T>)

Execute a delegate action on all visual descendants of this dependency object of a particular type.

USE SPARINGLY.

This method walks the entire tree. Use of this method on large trees or excessively will introduce a performance hit.

TraverseVisualTreeReverse<T>(DependencyObject, Action<T>)

In reverse order: Execute a delegate action on all visual descendants of this dependency object of a particular type.

USE SPARINGLY.

This method walks the entire tree. Use of this method on large trees or excessively will introduce a performance hit.

Applies to