MapSuiteGisEditor/MapSuiteGisEditor/UserControls/StringToHyperlinkXamlConverter.cs
/// <summary>
/// Converts a string containing valid XAML into WPF objects.
/// </summary>
/// <param name="value">The string to convert.</param>
/// <param name="targetType">This parameter is not used.</param>
/// <param name="parameter">This parameter is not used.</param>
/// <param name="culture">This parameter is not used.</param>
/// <returns>A WPF object.</returns>
Converts a string containing valid XAML into WPF objects.
Converts a string containing valid XAML into WPF objects .
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string input = value as string;
            if (input != null)
            {
                string escapedXml = SecurityElement.Escape(input);
                string withTags = escapedXml.Replace("purchase a subscription", "<TextBlock><Hyperlink NavigateUri=\"mark\" Style=\"{DynamicResource HyperlinkStyle}\">purchase a subscription</Hyperlink></TextBlock>");
                string wrappedInput = string.Format("<TextBlock xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" TextWrapping=\"Wrap\">{0}</TextBlock>", withTags);
                using (StringReader stringReader = new StringReader(wrappedInput))
                {
                    using (XmlReader xmlReader = XmlReader.Create(stringReader))
                    {
                        return XamlReader.Load(xmlReader);
                    }
                }
            }
            return null;
        }
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture ) { string input = value as string ; if ( input != null ) { string escapedXml = SecurityElement . Escape ( input ) ; string withTags = escapedXml . Replace ( " " , " \" \" \" \" " ) ; string wrappedInput = string . Format ( " \" \" \" \" " , withTags ) ; using ( StringReader stringReader = new StringReader ( wrappedInput ) ) { using ( XmlReader xmlReader = XmlReader . Create ( stringReader ) ) { return XamlReader . Load ( xmlReader ) ; } } } return null ; }
Converts a string containing valid XAML into WPF objects.
Converts a string containing valid XAML into WPF objects .
A WPF object.
A WPF object .
value
object
The string to convert.
The string to convert .
targetType
Type
This parameter is not used.
This parameter is not used .
parameter
object
This parameter is not used.
This parameter is not used .
culture
CultureInfo
This parameter is not used.
This parameter is not used .