Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converter returning Segoe MDL2 icon after binding does not work

I'm trying to bind the PlayerFramework.MediaPlayer.CanPause Property to a Button in my windows 10 universal app. This works using the default font, but when I switch to Segoe MDL2 to get those 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 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 shows the expected value

&#xE102;

which, directly set as the button content, shows the play symbol.

Any ideas why this doesn't work?

edit: Copying the character from the character table and returning it does work.

like image 618
Rob Avatar asked Aug 26 '15 03:08

Rob


1 Answers

&#xE102; is a unicode character escape sequence in XML (and hence also in XAML). In C# it is written as \uE102.

So the converter should return strings (or characters) with proper C# unicode character escape sequences:

public object Convert(object value, Type targetType, object parameter, string language)
{
    return (bool)value ? "\uE769" : "\uE102";
}
like image 140
Clemens Avatar answered Nov 16 '22 21:11

Clemens