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
Identifier field | UriSourceProperty |
Metadata properties set to true |
None |
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET