1


Stucked a bit with a pretty simple problem. In my app - I have a ComboBox with a list of FontAwesome icons. I describe them like unicode in a text property of a TextBlock.
Like:

<ComboBoxItem Padding="2">
    <TextBlock Style="{StaticResource FontAwesome}" 
               Text="&#xf039;"/>
</ComboBoxItem>

All good, I see the list of icons in the ComboBox.
Now, as a first item, I want to see the current assigned to the object icon, so I do like this:

<ComboBoxItem Padding="2">
    <TextBlock Style="{StaticResource FontAwesome}" 
               Text="{Binding Icon}" />
</ComboBoxItem>

The binded value Icon holds string Icon = "& #xf039;" (without the space) and now, my first item, which is binded to Icon displays not the icon, but the unicode value of the icon.
I pretty much can understand that it is happening because of it is getting saved as a string and is getting passed as a string, literally, but what can be a workaround from here? Include a converter I suppose would not help. But What can help is to save value of Icon as some else, instead of string and what can be represented as a Text property.

Will be very appreciated for some clues.

1 Answer 1

4

When creating the Icon string in code behind, it should contain a C# unicode character escape sequence instead of a XML (or XAML) unicode character escape sequence:

Icon = "\uF039";

Not the answer you're looking for? Browse other questions tagged or ask your own question.