Skip to content

Windows RT version - CanvasCanvas.MeasureText is not working correctly #55

@soernt

Description

@soernt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions