public Size MeasureText(VirtualCanvas parent, String label) { if (_parent != parent) { FontFamily fontFamily = (FontFamily)parent.GetValue(TextBlock.FontFamilyProperty); FontStyle fontStyle = (FontStyle)parent.GetValue(TextBlock.FontStyleProperty); FontWeight fontWeight = (FontWeight)parent.GetValue(TextBlock.FontWeightProperty); FontStretch fontStretch = (FontStretch)parent.GetValue(TextBlock.FontStretchProperty); _fontSize = (Double)parent.GetValue(TextBlock.FontSizeProperty); _typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); _parent = parent; } FormattedText ft = new FormattedText(label, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, _typeface, _fontSize, Brushes.Black); return(new Size(ft.Width, ft.Height)); }