0 out of 1 rated this helpful - Rate this topic

Image.Source Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets or sets the ImageSource for the image.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public ImageSource Source { get; set; }
<object Source="imageUri"/>
For XAML information, see the ImageSource type.

XAML Values

imageUri

System.String

A URI of the image file.

Property Value

Type: System.Windows.Media.ImageSource
The source of the drawn image. The default value is null.

Identifier field

SourceProperty

Metadata properties set to true

AffectsMeasure,

AffectsRender

The following example demonstrates how to use the Source property.


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;



<Image Source="smiley_stackpanel.png" Stretch="Fill"/>


More Code

How to: Use the Image ElementThis example shows how to include images in an application by using the Image element.
How to: Use a Drawing as an Image SourceThis example shows how to use a Drawing as the Source for an Image control. To display a Drawing with an Image control, use a DrawingImage as the Image control's Source and set the DrawingImage object's DrawingImage.Drawing property to the drawing you want to display.
How to: Crop an ImageThis example shows how to crop an image using CroppedBitmap.
How to: Rotate an ImageThis example shows how to rotate an image 90 degrees by using a Rotation property of a BitmapImage.
How to: Convert an Image to GreyscaleThis example shows how to convert an image to grayscale using FormatConvertedBitmap.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8 Consumer Preview, Windows Server 8 Beta, Windows 7, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.