NControl icon indicating copy to clipboard operation
NControl copied to clipboard

Windows RT version - CanvasCanvas.MeasureText is not working correctly

Open soernt opened this issue 8 years ago • 0 comments

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

soernt avatar Mar 08 '16 17:03 soernt