public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            XName name = value as XName;

            if (destinationType == typeof(string) && name != null)
            {
                if (name.Namespace == XNamespace.None)
                {
                    // return unqualified name
                    return(name.LocalName);
                }
                else
                {
                    string result = (string)(XNameTypeConverterHelper.ConvertTo(context, value, destinationType) ??
                                             base.ConvertTo(context, culture, value, destinationType));
                    if (IsQualifiedName(result))
                    {
                        return(result);
                    }
                    else
                    {
                        // The name is in the default XAML namespace, so we need to fully-qualify it,
                        // or we'll interpret it as unqualified in ConvertFrom
                        // Also need to escape the {} so it doesn't get interpreted as MarkupExtension
                        return(name.ToString().Replace("{", "{{").Replace("}", "}}"));
                    }
                }
            }
            else
            {
                return(XNameTypeConverterHelper.ConvertTo(context, value, destinationType) ??
                       base.ConvertTo(context, culture, value, destinationType));
            }
        }
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            XName name = value as XName;

            if ((destinationType == typeof(string)) && (name != null))
            {
                if (name.Namespace == XNamespace.None)
                {
                    return(name.LocalName);
                }
                string str = (string)(XNameTypeConverterHelper.ConvertTo(context, value, destinationType) ?? base.ConvertTo(context, culture, value, destinationType));
                if (this.IsQualifiedName(str))
                {
                    return(str);
                }
                return(name.ToString().Replace("{", "{{").Replace("}", "}}"));
            }
            return(XNameTypeConverterHelper.ConvertTo(context, value, destinationType) ?? base.ConvertTo(context, culture, value, destinationType));
        }