--- title: "How to: Draw Text to a Visual" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "typography [WPF], drawing text to visuals" - "visuals [WPF], drawing text to" - "text [WPF], drawing to visuals" - "drawing [WPF], text to visuals" ms.assetid: fee4003c-e8a6-46ec-babd-2c7f4231a101 --- # How to: Draw Text to a Visual The following example shows how to draw text to a using a object. A drawing context is returned by calling the method of a object. You can draw graphics and text into a drawing context. To draw text into the drawing context, use the method of a object. When you are finished drawing content into the drawing context, call the method to close the drawing context and persist the content. ## Example [!code-csharp[DrawingVisualSample#110](~/samples/snippets/csharp/VS_Snippets_Wpf/DrawingVisualSample/CSharp/Window1.xaml.cs#110)] [!code-vb[DrawingVisualSample#110](~/samples/snippets/visualbasic/VS_Snippets_Wpf/DrawingVisualSample/visualbasic/window1.xaml.vb#110)] > [!NOTE] > For the complete code sample from which the preceding code example was extracted, see [Hit Test Using DrawingVisuals Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Visual%20Layer/DrawingVisual).