Microsoft.Windows.Controls.Ribbon.RibbonComboBox.ExtractString C# (CSharp) Method

ExtractString() private static method

private static ExtractString ( DependencyObject d ) : string
d System.Windows.DependencyObject
return string
        private static string ExtractString(DependencyObject d)
        {
            TextBlock text;
            Visual visual;
            TextElement textElement;
            string strValue = String.Empty;

            if ((text = d as TextBlock) != null)
            {
                strValue = text.Text;
            }
            else if ((visual = d as Visual) != null)
            {
                int count = VisualTreeHelper.GetChildrenCount(visual);
                for (int i = 0; i < count; i++)
                {
                    strValue += ExtractString((DependencyObject)(VisualTreeHelper.GetChild(visual, i)));
                }
            }
            else if ((textElement = d as TextElement) != null)
            {
                strValue += textElement.ContentStart.GetTextInRun(LogicalDirection.Forward);
            }

            return strValue;
        }