BitmapImage.UriSource Property
.NET Framework 4
Gets or sets the Uri source of the BitmapImage.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
If StreamSource and UriSource are both set, the StreamSource value is ignored.
The following example demonstrates the use the UriSource property in Extensible Application Markup Language (XAML) and code.
<!-- Property Tag XAML Syntax --> <Image Width="200" Margin="5" Grid.Column="1" Grid.Row="1" > <Image.Source> <BitmapImage UriSource="sampleImages/bananas.jpg" /> </Image.Source> </Image>
// 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.BeginInit(); bi.UriSource = new Uri(@"/sampleImages/cherries_larger.jpg",UriKind.RelativeOrAbsolute); bi.EndInit(); // Set the image source. simpleImage.Source = bi;
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.