None
None

Reputation: 5670

Dynamic generated FontIcon is not displaying correctly (UWP)

I want to put a font icon inside a Grid. If I do it with XAML like this

   <FontIcon  Glyph="&#xE96F;"/>

It works fine. But when I try to add the same item dynamically it is not working (instead of icon some wiered symbols coming). Dynamic code as follows

                    var fic = new FontIcon {Glyph = "&#xE970" };
                    Grid.SetColumn(fic, col);
                    grdSearchResultHeader.Children.Add(fic);

dynamically added Output looks like this

enter image description here

And the Xaml added one looks correct like this

enter image description here

How can I solve this issue?

Upvotes: 0

Views: 129

Answers (1)

Anran Zhang
Anran Zhang

Reputation: 7727

&#xE970; is the escaped text and can only be used in XAML (or similar XML). In C# you don’t need to escape, you just need to type \uE970.

Thanks.

Upvotes: 3

Related Questions