Gets or sets the source for the image.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
Dependency property identifier field: SourceProperty
You can set the by specifying an absolute URL (e.g. http://contoso.com/myPicture.jpg) or specify a URL relative to the XAP file of your application.
You can set this property in XAML, but in this case you are setting the property as a URI. The XAML 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 ImageFailed event can occur if the initial attribute value in XAML does not specify a valid source.
The following example shows how to create an image.
Image myImage = new Image(); myImage.Source = new BitmapImage(new Uri("myPicture.jpg", UriKind.RelativeOrAbsolute)); LayoutRoot.Children.Add(myImage);
In this example, the property is used to specify the location of the image you want to display. You can set the by specifying an absolute URL (e.g. http://contoso.com/myPicture.jpg) or specify a URL relative to the XAP file of your application. So for the previous example, you would need to have the XAP file in the same folder as myPicture.png.