Share via


BitmapImage.UriSource 屬性

定義

取得或設定 UriBitmapImage 來源。

public:
 property Uri ^ UriSource { Uri ^ get(); void set(Uri ^ value); };
public Uri UriSource { get; set; }
member this.UriSource : Uri with get, set
Public Property UriSource As Uri

屬性值

Uri

UriBitmapImage 來源。 預設為 null

範例

下列範例示範如何使用 UriSource Extensible Application Markup Language (XAML) 和程式碼中的 屬性。

<!-- 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>
<!-- 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;
' 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

備註

如果 StreamSourceUriSource 都已設定,則會 StreamSource 忽略此值。

相依性屬性資訊

識別碼欄位 UriSourceProperty
設定為 的中繼資料屬性 true

適用於

另請參閱