Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).
Public NotInheritable Class BitmapImage _ Inherits BitmapSource _ Implements ISupportInitialize, IUriContext
Dim instance As BitmapImage
public sealed class BitmapImage : BitmapSource, ISupportInitialize, IUriContext
public ref class BitmapImage sealed : public BitmapSource, ISupportInitialize, IUriContext
public final class BitmapImage extends BitmapSource implements ISupportInitialize, IUriContext
<BitmapImage .../>
BitmapImage primarily exists to support Extensible Application Markup Language (XAML) syntax and introduces additional properties for bitmap loading that are not defined by BitmapSource.
BitmapImage implements the ISupportInitialize interface to optimize initialization on multiple properties. Property changes can only occur during object initialization. Call BeginInit to signal that initialization has begun and EndInit to signal that initialization has completed. After initialization, property changes are ignored.
BitmapImage objects created using the BitmapImage constructor are automatically initialized and property changes are ignored.
The following code examples demonstrate how to use a BitmapImage 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. Dim simpleImage As New Image() simpleImage.Width = 200 simpleImage.Margin = New Thickness(5) ' Create source. Dim bi As 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
// 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 Vista