* 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
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 |
|
|
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.