Image.Source Property
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 ImageSource for the image.
public:
property System::Windows::Media::ImageSource ^ Source { System::Windows::Media::ImageSource ^ get(); void set(System::Windows::Media::ImageSource ^ value); };
C#
public System.Windows.Media.ImageSource Source { get; set; }
member this.Source : System.Windows.Media.ImageSource with get, set
Public Property Source As ImageSource
The source of the drawn image. The default value is null
.
The following example demonstrates how to use the Source property.
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;
C#
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
XAML
<Image Source="smiley_stackpanel.png" Stretch="Fill"/>
<object Source="imageUri"/>
For XAML information, see the ImageSource type.
imageUri System.String
A URI of the image file.
Item | Value |
---|---|
Identifier field | SourceProperty |
Metadata properties set to true |
AffectsMeasure, AffectsRender |
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: