ImageSource Property
Collapse the table of content
Expand the table of content

ImageBrush.ImageSource Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the image displayed by this ImageBrush.

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

public ImageSource ImageSource { get; set; }
<ImageBrush ImageSource="imageUri"/>

XAML Values


A URI that references an image file. See "Setting ImageSource in XAML" section in Remarks for this topic.

Property Value

Type: System.Windows.Media.ImageSource
The image displayed by this ImageBrush.

Dependency property identifier field: ImageSourceProperty

The XAML usage for ImageSource is significantly different than the code usage. The XAML usage uses a URI whereas the code usage uses an ImageSource. See "Setting ImageSource in XAML" section of this topic.

In the code usage, the equivalent ImageSource property can be set by a string that is evaluated as a URI. This property uses an underlying ImageSource instance (actually this is usually a BitmapImage, which is a derived class).

See BitmapImage for information on the types of image sources and formats that can be used for an Image.

Setting ImageSource in XAML

You can set this property in XAML, but in this case you are setting the ImageSource property as a URI. This behavior relies on underlying type conversion that processes the string as a URI, and calls the BitmapImage(Uri) constructor. This in turn potentially requests a stream from that URI and returns the image source object.

The string provided for the property is interpreted as a Uniform Resource Identifier (URI). This is in contrast to an Internationalized Resource Identifier (IRI). This distinction means that characters used to identify a ImageSource that are outside of US-ASCII will need to be encoded.

The format-specific filename extensions for the supported image formats are not required to be in the URI naming. However, if the retrieved file is a valid image format when it is opened or processed, a runtime exception is thrown.

The ImageFailed event can occur if the initial ImageSource attribute value in XAML does not specify a valid source.

You can use a relative URI to reference an image that you package with the application, or an absolute URI to reference an image from a server.


You can specify an initial XAML value of "" (empty string) and then set the value in script at a later time, to create a nonrendering placeholder.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft