protected override Size MeasureOverride(Size availableSize)
{
typeface = this.CreateTypeface();
emSize = (double)GetValue(TextBlock.FontSizeProperty);
FormattedText text = new FormattedText(
new string('9', maxLineNumberLength),
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
emSize,
(Brush)GetValue(Control.ForegroundProperty)
);
return new Size(text.Width, 0);
}