CK.WPF.Controls.TextBlockService.CalculateIsTextTrimmed C# (CSharp) Method

CalculateIsTextTrimmed() private static method

private static CalculateIsTextTrimmed ( System.Windows.Controls.TextBlock textBlock ) : bool
textBlock System.Windows.Controls.TextBlock
return bool
        private static bool CalculateIsTextTrimmed( TextBlock textBlock )
        {
            if( !textBlock.IsArrangeValid )
            {
                return GetIsTextTrimmed( textBlock );
            }

            Typeface typeface = new Typeface( textBlock.FontFamily, textBlock.FontStyle, textBlock.FontWeight, textBlock.FontStretch );

            // FormattedText is used to measure the whole width of the text held up by TextBlock container
            FormattedText formattedText = new FormattedText( textBlock.Text, System.Threading.Thread.CurrentThread.CurrentCulture, textBlock.FlowDirection, typeface, textBlock.FontSize, textBlock.Foreground );

            //formattedText.MaxTextWidth = textBlock.ActualWidth;

            // When the maximum text width of the FormattedText instance is set to the actual
            // width of the textBlock, if the textBlock is being trimmed to fit then the formatted
            // text will report a larger height than the textBlock. Should work whether the
            // textBlock is single or multi-line.
            return (formattedText.Width > textBlock.ActualWidth);
        }