从后面的代码设置TextBox的字体

Jie*_*eng 34 c# wpf code-behind

这可能是一个愚蠢的问题,但我怎么设置的字体TextBoxstring后面的代码?

// example
txtEditor.FontFamily = "Consolas";
Run Code Online (Sandbox Code Playgroud)

Gis*_*shu 55

txtEditor.FontFamily = new FontFamily("Consolas"); // the Media namespace
Run Code Online (Sandbox Code Playgroud)


小智 18

使用以下语法:

lblCounting.Font  = new Font("Times New Roman", 50);
Run Code Online (Sandbox Code Playgroud)

lblCounting只是任何标签.


小智 7

System.Drawing.Font = new Font("Arial", 8, FontStyle.Bold);
Run Code Online (Sandbox Code Playgroud)