var formattedText = new FormattedText(
Txbox.Text,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
new Typeface(Txbox.FontFamily, Txbox.FontStyle, Txbox.FontWeight, Txbox.FontStretch),
Txbox.FontSize,
Brushes.Black);
Size size = new Size(formattedText.Width, formattedText.Height);