0
我有一些Text =「AAAAAAAA」,FontFamily =「Arial」,FontSize =「16」的TextBlock。如何將文本轉換爲WPF像素?如何將字符串轉換爲像素
我有一些Text =「AAAAAAAA」,FontFamily =「Arial」,FontSize =「16」的TextBlock。如何將文本轉換爲WPF像素?如何將字符串轉換爲像素
你可以使用FormattedText
測量:
FormattedText formattedText = new FormattedText(
"AAAAAAAA",
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface("Arial"), 16, Brushes.Black
);
MessageBox.Show(formattedText.Width.ToString());