【发布时间】:2016-06-28 09:36:33
【问题描述】:
在 WPF 中,这可以使用 FormattedText,如下所示:
private Size MeasureString(string candidate)
{
var formattedText = new FormattedText(
candidate,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
new Typeface(this.textBlock.FontFamily, this.textBlock.FontStyle, this.textBlock.FontWeight, this.textBlock.FontStretch),
this.textBlock.FontSize,
Brushes.Black);
return new Size(formattedText.Width, formattedText.Height);
}
但是在 UWP 中这个类已经不存在了。那么在通用windows平台中如何计算文本尺寸呢?
【问题讨论】:
标签: c# uwp win-universal-app