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 @"";
// "play"
return "";
}
...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

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.

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";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With