Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
soernt opened this issue Mar 8, 2016 · 0 comments
Open

Comments

@soernt
Copy link

soernt commented Mar 8, 2016

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 soernt changed the title Windows Phone RT version - CanvasCanvas.MeasureText is not working correctly Windows RT version - CanvasCanvas.MeasureText is not working correctly Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant