Export (0) Print
Expand All

Image.Source Property

Gets or sets the ImageSource for the image. This is a dependency property.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public ImageSource Source { get; set; }
/** @property */
public ImageSource get_Source ()

/** @property */
public void set_Source (ImageSource value)

public function get Source () : ImageSource

public function set Source (value : ImageSource)

<object Source="imageUri"/>
 For XAML information, see the ImageSource type. 
 imageUri   System.String  A URI of the image file. 

Property Value

The source of the drawn image. The default value is a null reference (Nothing in Visual Basic).

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 Element

This example shows how to include images in an application using the Image element.

How to: Use a Drawing as an Image Source

This 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 Image

This example shows how to crop an image using CroppedBitmap.

How to: Rotate an Image

This example shows how to rotate an image 90 degrees by using a Rotation property of a BitmapImage.

How to: Convert an Image to Greyscale

This example shows how to convert an image to grayscale using FormatConvertedBitmap.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft