Converter returning Segoe MDL2 icon after binding does not work

I am trying to bind the PlayerFramework.MediaPlayer.CanPause property to a button in my universal Windows 10 application. It works using the default font, but when I switch to Segoe MDL2 to get these fancy icons, the button shows garbage.

<mmppf:MediaPlayer x:Name="mediaElement"> ... <Button Name="btnPlay" Style="{StaticResource transportStyle}" Content="{Binding CanPause, ElementName=mediaElement, Converter={StaticResource CanPauseToPlayPauseConverter}}"/> 

This is from the converter:

 public object Convert(object value, Type targetType, object parameter, string language) { bool canPause = (bool)value; if (canPause) return @"&#xE769;"; // "play" return "&#xE102;"; } 

... and this is from the button style:

 <Style x:Name="transportStyle" TargetType="Button"> <!-- <Setter Property="FontFamily" Value="Segoe MDL2 Assets" />--> </Style> 

After disabling the Setter property, the button displays the expected value.

 &#xE102; 

which is directly set as the contents of the button, shows a play character.

Any ideas why this is not working?

edit: Copy a character from the character table and return it to work.

+5
source share
2 answers

&#xE102; is the Unicode character escape sequence in XML (and therefore also in XAML). In C #, it is written as \uE102 .

Thus, the converter should return strings (or characters) with the corresponding Unicode # escape sequences:

 public object Convert(object value, Type targetType, object parameter, string language) { return (bool)value ? "\uE769" : "\uE102"; } 
+10
source

You should return char not a string:

 public object Convert(object value, Type targetType, object parameter, string language) { bool canPause = (bool)value; if (canPause) return '\xE769'; // "play" return '\xE102'; } 
-1
source

All Articles