Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-draw-text-to-a-visual.md
T
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

1.6 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Draw Text to a Visual 03/30/2017
csharp
vb
typography [WPF], drawing text to visuals
visuals [WPF], drawing text to
text [WPF], drawing to visuals
drawing [WPF], text to visuals
fee4003c-e8a6-46ec-babd-2c7f4231a101

How to: Draw Text to a Visual

The following example shows how to draw text to a xref:System.Windows.Media.DrawingVisual using a xref:System.Windows.Media.DrawingContext object. A drawing context is returned by calling the xref:System.Windows.Media.DrawingVisual.RenderOpen%2A method of a xref:System.Windows.Media.DrawingVisual object. You can draw graphics and text into a drawing context.

To draw text into the drawing context, use the xref:System.Windows.Media.DrawingContext.DrawText%2A method of a xref:System.Windows.Media.DrawingContext object. When you are finished drawing content into the drawing context, call the xref:System.Windows.Media.DrawingContext.Close%2A method to close the drawing context and persist the content.

Example

[!code-csharpDrawingVisualSample#110] [!code-vbDrawingVisualSample#110]

Note

For the complete code sample from which the preceding code example was extracted, see Hit Test Using DrawingVisuals Sample.