BitmapImage.UriSource 屬性

定義

取得或設定 UriBitmapImage 來源。Gets or sets the Uri source of the BitmapImage.

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 來源。The Uri source of the BitmapImage. 預設為 nullThe default is null.

範例

下列範例示範如何在和程式UriSource代碼中Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)使用屬性。The following example demonstrates the use the UriSource property in Extensible Application Markup Language (XAML)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>
<!-- 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

備註

如果StreamSource同時UriSource設定了和, 則StreamSource會忽略此值。If StreamSource and UriSource are both set, the StreamSource value is ignored.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field UriSourceProperty
中繼資料屬性設定為trueMetadata properties set to true None

適用於

另請參閱