Bluecomb
Bluecomb

Reputation: 11

Textblock binding issues with converter

I am trying to use the font icon in my TextMlock control to display specific icon. For this, I use text block binded with some text which is converted through a converter to a specific symbol code. But instead of displaying that particular symbol the text block is displaying the symbol code without &# characters. Am I doing something wrong here?

Converter class:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
    var catagoryString = value?.ToString().Trim();
    var returnString = string.Empty;
    if (stringConditionOne)
    {
        return "";
    }
    if (strinConditionTwo)
    {
        return @"🔖";
    }
    return "";
}

Textblock binding:

<TextBlock
    Grid.Row="0"
    Grid.Column="4"
    FontFamily="Segoe UI Symbol"
    FontSize="10"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    Text="{Binding TextProperty, Converter={StaticResource stringToSymbolConvertor}}"
    TextAlignment="Center" />

Upvotes: 0

Views: 88

Answers (1)

paparazzo
paparazzo

Reputation: 45096

From code behind use \u

"\ue1ef;"

Upvotes: 1

Related Questions