BitmapImage.UriSource Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
The Uri source of the BitmapImage. The default is null
.
Examples
The following example demonstrates the use the UriSource property 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>
<!-- 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
Remarks
If StreamSource and UriSource are both set, the StreamSource value is ignored.
Dependency Property Information
Item | Value |
---|---|
Identifier field | UriSourceProperty |
Metadata properties set to true |
None |
Applies to
See also
Spolupracujte s námi na GitHubu
Zdroj tohoto obsahu najdete na GitHubu, kde můžete také vytvářet a kontrolovat problémy a žádosti o přijetí změn. Další informace najdete v našem průvodci pro přispěvatele.