Image.Source 屬性

定義

取得或設定影像的 ImageSource

public:
 property System::Windows::Media::ImageSource ^ Source { System::Windows::Media::ImageSource ^ get(); void set(System::Windows::Media::ImageSource ^ value); };
public System.Windows.Media.ImageSource Source { get; set; }
member this.Source : System.Windows.Media.ImageSource with get, set
Public Property Source As ImageSource

屬性值

已繪製影像的來源。 預設值是 null

範例

下列範例示範如何使用 Source 屬性。

Image^ myImage3 = gcnew Image();
BitmapImage^ bi3 = gcnew BitmapImage();
bi3->BeginInit();
bi3->UriSource = gcnew System::Uri("smiley_stackpanel.PNG", UriKind::Relative);
bi3->EndInit();
myImage3->Stretch = Stretch::Fill;
myImage3->Source = bi3;
Image myImage3 = new Image();
BitmapImage bi3 = new BitmapImage();
bi3.BeginInit();
bi3.UriSource = new Uri("smiley_stackpanel.PNG", UriKind.Relative);
bi3.EndInit();
myImage3.Stretch = Stretch.Fill;
myImage3.Source = bi3;
Dim myImage3 As New Image
Dim bi3 As New BitmapImage
bi3.BeginInit()
bi3.UriSource = New Uri("smiley_stackpanel.PNG", UriKind.Relative)
bi3.EndInit()
myImage3.Stretch = Stretch.Fill
myImage3.Source = bi3
<Image Source="smiley_stackpanel.png" Stretch="Fill"/>

備註

XAML Attribute Usage

<object Source="imageUri"/>  

XAML 文字使用方式

如需 XAML 資訊,請參閱 ImageSource 類型。

XAML 值

imageUri
System.String

影像檔案的 URI。

相依性屬性資訊

識別碼欄位 SourceProperty
中繼資料屬性設定為 true AffectsMeasure,

AffectsRender

適用於