【问题标题】:Missing icon in Segoe MDL2 Assets font familySegoe MDL2 Assets 字体系列中缺少图标
【发布时间】:2019-09-11 21:15:58
【问题描述】:

我正在尝试创建一个 AppBarButton,其中图标属性是 FontIcon,但我要使用的特定图标不起作用;它显示为一个矩形。

我正在 C# 中创建一个 UWP 应用程序,我正在尝试使用 Segoe MDL2 Assets 字体中的 QR 码(Unicode 点 ED14)图标创建一个按钮,但是当我将图标标识符输入到 Glyph 属性中时FontIcon 元素它只是显示占位符矩形,就好像没有安装字体一样。我在我的应用中使用的所有其他图标都可以正常工作,但这个图标没有出现。

我确保复制工作按钮并简单地更改图标代码,但它不起作用。我还尝试将已知工作图标的代码放入损坏的按钮中,效果很好。此页面https://docs.microsoft.com/en-us/windows/uwp/design/style/segoe-ui-symbol-font上的二维码图标似乎有问题。

有问题的按钮:

<AppBarButton Label="QR Codes" Click="{x:Bind NewExhibitionAsync}">
    <AppBarButton.Icon>
        <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xED14;"/>
    </AppBarButton.Icon>
</AppBarButton>

完整的命令栏:

<CommandBar>
    <AppBarButton Label="Open...">
        <AppBarButton.Icon>
            <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE8E5;"/>
        </AppBarButton.Icon>
    </AppBarButton>
    <AppBarButton Icon="Save" Label="Save" />
    <AppBarButton Label="Save as...">
        <AppBarButton.Icon>
            <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE792;"/>
        </AppBarButton.Icon>
    </AppBarButton>

    <AppBarSeparator/>

    <AppBarButton Icon="Add" Label="New Exhibition" Click="{x:Bind NewExhibitionAsync}"/>
    <AppBarButton Label="QR Codes" Click="{x:Bind NewExhibitionAsync}">
        <AppBarButton.Icon>
            <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xED14;"/>
        </AppBarButton.Icon>
    </AppBarButton>
    <AppBarButton Label="Set Primary Photo" Click="{x:Bind SetStarred}" IsEnabled="{x:Bind SetStarredEnabled, Mode=OneWay}">
        <AppBarButton.Icon>
            <SymbolIcon Symbol="SolidStar" Foreground="Goldenrod"/>
        </AppBarButton.Icon>
    </AppBarButton>

    <AppBarSeparator/>

    <AppBarButton Icon="Delete" Label="Delete" Click="{x:Bind DeleteArtefactAsync}" IsEnabled="{x:Bind DeleteArtefactEnabled, Mode=OneWay}"/>
    <AppBarButton Icon="Edit" Label="Edit" Click="{x:Bind EditArtefactAsync}" IsEnabled="{x:Bind EditArtefactEnabled, Mode=OneWay}"/>
</CommandBar>

上面的代码当前在放入CommandBar时显示如下图。

有没有人知道如何让图标显示在 Microsoft 文档中?它应该看起来像这个图像。 (抱歉,没有足够的声誉来正确发布图片。)

【问题讨论】:

    标签: c# xaml fonts uwp icons


    【解决方案1】:

    出现这个问题,说明你的系统版本可能较低。

    Segoe MDL2 Assets为系统图标字体,随系统更新而变化。二维码图标稍后出现,在低版本系统中不可用。

    所以请尝试更新您的系统。或者复制高版本系统上的字体,安装到低版本系统上

    最好的问候。

    【讨论】:

    • 这就是解决方案。我不敢相信我没想过要检查我的电脑是否有更新。我运行的是版本 18**,现在已更新到 1903。感谢您的帮助。
    【解决方案2】:

    只是添加到@Richard Zhang 的答案 - MSFT,如果您的目标设备版本低于您想要在您的应用程序中使用的字体图标或表情符号,那么正确的解决方案可能是不使用这个特定的图标。相反,使用带有png 版本图标的BitmapIcon 或者甚至更好的是带有提取的图标本身的SVG 路径的PathIcon

    幸运的是,您可以通过Icons8Syncfusion Metro Studio 等服务在线找到许多可以在您的应用中使用的合适图标。

    对于表情符号,您可以在https://emojipedia.org/ 查看版本支持。不幸的是,我不知道 MDL2 资产字体的类似来源。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多