Net Core教程

WPF C# Canvas上绘制文字

本文主要是介绍WPF C# Canvas上绘制文字,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
 private void drawText(double x, double y, string text, Color color,Canvas canvasObj)
        { 
            TextBlock textBlock = new TextBlock(); 
            textBlock.Text = text; 
            textBlock.Foreground = new SolidColorBrush(color); 
            Canvas.SetLeft(textBlock, x); 
            Canvas.SetTop(textBlock, y); 
            canvasObj.Children.Add(textBlock); 
        }

  

 drawText(l.X1, l.Y1,"Text", Color.FromRgb(200, 0, 0), myCanvas);

  

这篇关于WPF C# Canvas上绘制文字的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!