Image.Source Property

Definition

Gets or sets the ImageSource for the image.

C#
public System.Windows.Media.ImageSource Source { get; set; }

Property Value

The source of the drawn image. The default value is null.

Examples

The following example demonstrates how to use the Source property.

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;
XAML
<Image Source="smiley_stackpanel.png" Stretch="Fill"/>

Remarks

XAML Attribute Usage

<object Source="imageUri"/>

XAML Text Usage

For XAML information, see the ImageSource type.

XAML Values

imageUri System.String

A URI of the image file.

Dependency Property Information

Item Value
Identifier field SourceProperty
Metadata properties set to true AffectsMeasure,

AffectsRender

Applies to

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