private Size MeasureString()
{
var formattedText = new FormattedText(
this.myabc.Text,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(this.myabc.FontFamily, this.myabc.FontStyle, this.myabc.FontWeight, this.myabc.FontStretch),
this.myabc.FontSize,
Brushes.Black,
new NumberSubstitution(),
TextFormattingMode.Ideal);
formattedText.TextAlignment = TextAlignment.Right;
return new Size(formattedText.Width, formattedText.Height);
}
WPF 测量字符串显示大小
最新推荐文章于 2023-01-20 14:32:45 发布