我正在使用xaml通用项目,并且在转换为后面的代码中的字符串后显示字体Segoe MDL2资产的某些字符时出现问题。请查看图片和任何有ideia的人如何解决这个问题:
的Xaml:
<converters:MyTypeConv x:Key="myTypeConv" />
<dSrc:clsLstElem x:Key="lstCmdAnsw">
<dSrc:clsElem iAuto="0" />
<dSrc:clsElem iAuto="1" />
<dSrc:clsElem iAuto="2" />
</dSrc:clsLstElem>
Xaml用法:
<Border CornerRadius="5" BorderBrush="Black" BorderThickness="1">
<ItemsControl ItemsSource="{StaticResource lstCmdAnsw}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button
Content="{Binding iAuto, Mode=OneWay, Converter={StaticResource myTypeConv}}"
FontFamily="Segoe MDL2 Assets"
FontSize="{ThemeResource ContentControlFontSize}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
代码背后:
public class MyTypeConv : Windows.UI.Xaml.Data.IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, string language)
{
string s = string.Empty;
if (value != null)
{
switch ((int)value)
{
case 0:
s = "\uE81D";
break;
case 1:
s = "\uE927;";
break;
case 2:
s = "\uE916;;";
break;
}
}
return s;
}
}