Files
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.0 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Use a Drawing as an Image Source 03/30/2017
graphics [WPF], drawings [WPF], as image sources
image sources [WPF], drawings
drawings [WPF], as image sources
dcf71c7b-9e86-4b8e-8e39-0d0ce0389ef4

How to: Use a Drawing as an Image Source

This example shows how to use a xref:System.Windows.Media.Drawing as the xref:System.Windows.Controls.Image.Source%2A for an xref:System.Windows.Controls.Image control. To display a xref:System.Windows.Media.Drawing with an xref:System.Windows.Controls.Image control, use a xref:System.Windows.Media.DrawingImage as the xref:System.Windows.Controls.Image control's xref:System.Windows.Controls.Image.Source%2A and set the xref:System.Windows.Media.DrawingImage object's xref:System.Windows.Media.DrawingImage.Drawing%2A?displayProperty=nameWithType property to the drawing you want to display.

Example

The following example uses a xref:System.Windows.Media.DrawingImage and an xref:System.Windows.Controls.Image control to display a xref:System.Windows.Media.GeometryDrawing. This example produces the following output:

A GeometryDrawing of two ellipses
A DrawingImage

[!code-csharpDrawingMiscSnippets_snip#DrawingImageExampleWholePage] [!code-xamlDrawingMiscSnippets_snip#DrawingImageExampleWholePage]

See also