ImageBrush Class

July 28, 2014

Paints an area with an image.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public sealed class ImageBrush : TileBrush
<ImageBrush .../>

The ImageBrush type exposes the following members.

  NameDescription
Public methodImageBrushInitializes a new instance of the ImageBrush class.
Top

  NameDescription
Public propertyAlignmentXGets or sets the horizontal alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public propertyAlignmentYGets or sets the vertical alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public propertyDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertyImageSourceGets or sets the image displayed by this ImageBrush.
Public propertyOpacityGets or sets the degree of opacity of a Brush. (Inherited from Brush.)
Public propertyRelativeTransformGets or sets the transformation that is applied to the brush using relative coordinates. (Inherited from Brush.)
Public propertyStretchGets or sets a value that specifies how the content of this TileBrush stretches to fit its tiles. (Inherited from TileBrush.)
Public propertyTransformGets or sets the transformation that is applied to the brush. (Inherited from Brush.)
Top

  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAnimationBaseValueReturns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventImageFailedOccurs when there is an error associated with image retrieval or format.
Public eventImageOpenedOccurs when the image source is downloaded and decoded with no failure. You can use this event to determine the size of an image before rendering it.
Top

  NameDescription
Public fieldStatic memberImageSourcePropertyIdentifies the ImageSource dependency property.
Top

An ImageBrush paints an area with an ImageSource. The ImageSource subclass that is defined by Windows Phone is BitmapImage, which describes a bitmap graphic.

An ImageBrush is a type of TileBrush that defines its content as an image. You can control how the image is stretched, aligned, and tiled, enabling you to produce patterns and other effects.

If the ImageSource property is set to an invalid format, or is specified to a URI that cannot be resolved, then the ImageFailed event is raised.

The following XAML example shows how to set the Foreground property of a TextBlock to an ImageBrush, whose image is used as the fill for the TextBlock rendered text.


<!-- TextBlock with an image brush applied to the text. -->
<TextBlock FontFamily="Verdana" FontSize="72"
 FontStyle="Italic" FontWeight="Bold">
    SHRUBBERY
  <TextBlock.Foreground>
    <ImageBrush ImageSource="forest.jpg"/>
  </TextBlock.Foreground>
</TextBlock>


The following illustration shows the results of this XAML example.

The output of the code

Output from an ImageBrush.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft