BitmapImage.UriSource Property


Gets or sets the Uri source of the BitmapImage.

Namespace:   System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public Uri UriSource { get; set; }

Property Value

Type: System.Uri

The Uri source of the BitmapImage. The default is null.

If StreamSource and UriSource are both set, the StreamSource value is ignored.

Identifier field


Metadata properties set to true


The following example demonstrates the use the UriSource property in Extensible Application Markup Language (XAML) and code.

// Create the image element.
Image simpleImage = new Image();    
simpleImage.Width = 200;
simpleImage.Margin = new Thickness(5);

// Create source.
BitmapImage bi = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
bi.UriSource = new Uri(@"/sampleImages/cherries_larger.jpg",UriKind.RelativeOrAbsolute);
// Set the image source.
simpleImage.Source = bi;

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top