ImageBrush Object

Paints an area with an image.

XAML
<ImageBrush .../>
Scripting
To create an object using scripting, see CreateFromXAML.

Properties

AlignmentX, AlignmentY, DownloadProgress, ImageSource, Name, Opacity, RelativeTransform, Stretch, Transform

Methods

Equals, FindName, GetHost, GetValue, SetSource, SetValue

Events

DownloadProgressChanged

Remarks

An ImageBrush can be used to create a decorative effect for text in your application. For example, the Foreground property of the TextBlock can specify an ImageBrush.

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.

PNG Color Depth

Silverlight 1.0 does not support all possible color depths that are included in the PNG specification. The following are the PNG color depths supported in Silverlight 1.0.:

  • Indexed color: 1, 4, or 8 bit color depth (per channel).
  • Truecolor: 24 bit color depth, or 32 bit color depth (per channel) for truecolor plus alpha.

Notably, gray scale (with or without alpha), and 64-bit truecolor, are not supported in Silverlight 1.0.

Examples

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

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

The following screenshot shows the results of the previous XAML example.

An image file used by Image and ImageBrush objects

An image file used by Image and ImageBrush objects

See Also

Imaging Overview
Brush Overview
Brush
Image