共用方式為


BitmapImage.EndInit 方法

定義

表示 BitmapImage 初始化結束。

public:
 virtual void EndInit();
public void EndInit ();
abstract member EndInit : unit -> unit
override this.EndInit : unit -> unit
Public Sub EndInit ()

實作

例外狀況

UriSourceStreamSource 屬性為 null

-或-

EndInit() 方法在未呼叫 BeginInit() 的情況下先行呼叫。

範例

下列範例示範如何使用 和 EndInit 方法,以 BeginInit 一組屬性初始化 BitmapImage

// Define a BitmapImage.
Image myImage = new Image();
BitmapImage bi = new BitmapImage();

// Begin initialization.
bi.BeginInit();

// Set properties.
bi.CacheOption = BitmapCacheOption.OnDemand;
bi.CreateOptions = BitmapCreateOptions.DelayCreation;
bi.DecodePixelHeight = 125;
bi.DecodePixelWidth = 125;
bi.Rotation = Rotation.Rotate90;
MessageBox.Show(bi.IsDownloading.ToString());
bi.UriSource = new Uri("smiley.png", UriKind.Relative);

// End initialization.
bi.EndInit();
myImage.Source = bi;
myImage.Stretch = Stretch.None;
myImage.Margin = new Thickness(5);
' Define a BitmapImage.
Dim myImage As New Image()
Dim bi As New BitmapImage()

' Begin initialization.
bi.BeginInit()

' Set properties.
bi.CacheOption = BitmapCacheOption.OnDemand
bi.CreateOptions = BitmapCreateOptions.DelayCreation
bi.DecodePixelHeight = 125
bi.DecodePixelWidth = 125
bi.Rotation = Rotation.Rotate90
MessageBox.Show(bi.IsDownloading.ToString())
bi.UriSource = New Uri("smiley.png", UriKind.Relative)

' End initialization.
bi.EndInit()
myImage.Source = bi
myImage.Stretch = Stretch.None
myImage.Margin = New Thickness(5)

備註

必須在 和 EndInit 呼叫之間 BeginInit 完成屬性初始化。 BitmapImage初始化 之後,就會忽略屬性變更。

適用於

另請參閱