Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do the equivalent of a Graphics.DrawString() in WPF?

I'm creating a WPF application (in C#) and I need to be able to draw strings using the C# code, not the XAML. The strings will be changing rapidly, so whatever method I use should be able to reflect that. I like the graphics.drawstring method in windows forms. Is there anything similar I can use in WPF?

Edit: Creating FormattedText seems to be the answer, but what is the drawingContext? How do I find it? What I really want to do is put this text into the children of a canvas. How is that done?

like image 533
Stefan Avatar asked Aug 26 '09 17:08

Stefan


1 Answers

There is an entire section of MSDN explaining how to draw formatted text in WPF. This allows you to draw, via code, on any drawing context.

like image 136
Reed Copsey Avatar answered Sep 16 '22 16:09

Reed Copsey