Search code examples
c#windows-runtimewinrt-xamltextblock

How to measure the width of whitespace in windows store?


How can i measure the width of whitespace in winrt. I'm trying the below code for calculate the size,

For example,

var text = "    ";
TextBlock txtBlock = new TextBlock();
txtBlock.Text = text;
txtBlock.FontSize = 14;
...
txtBlock.Measure(size);
var actualWidth = txtBlock.ActualWidth;

But i'm getting width as 0. Please any one help me.


Solution

  • Call Measure() then Arrange() and then ActualWidth and ActualHeight will be updated. This works for me.