NControl
NControl copied to clipboard
Windows RT version - CanvasCanvas.MeasureText is not working correctly
MeasureText gives allways a an empty Size back. I repleaced the implementation with this one:
public Size MeasureText(string text, Font font)
{
if (text == " ")
{
text = "\u00A0";
}
var textBlock = new TextBlock
{
Text = text,
FontFamily = new FontFamily(font.Family),
FontSize = font.Size,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left
};
textBlock.Measure(new Windows.Foundation.Size(double.MaxValue, double.MaxValue));
return new Size(textBlock.DesiredSize.Width, textBlock.DesiredSize.Height);
}
Now it is working for me.
Regards, Sörnt