Set Segoe UI Symbol font programmatically

kkoscielniak picture kkoscielniak · Jun 24, 2013 · Viewed 8.4k times · Source

I learn Windows Phone programming. Since I got Lumia 610 (WP7.8), I write in 7.1 SDK. The problem is I want my app to concatenate string with an arrow symbol, which is available in Segoe UI Symbol font. But when I try to force programme programmatically to use Segoe UI Font it doesn't work (it shows only a &#x 2708; string). When I'm forcing using for e.g. Comic Sans MS - there's no problem.

this.lExercise.Text = "zxcv";
                this.lExercise.Inlines.Add(new Run()
                {
                    Text = "✈",
                    FontFamily = new FontFamily("Segoe UI Symbol")                       
                });
                this.lExercise.Inlines.Add(new Run() { Text = " asdf", FontSize = 36 });

Any ideas appreciated :)

Answer

keyboardP picture keyboardP · Jun 24, 2013

The symbol for a right arrow is U+2192. The string you're using (✈) has been escaped so that it can be used in XAML. When using it in code, you use \u2192 to let it know that it's a symbol. So it should be

Text = "\u2192", //or \u2708 if you want the plane symbol