[UWP] [XAML] FontIcon在使用C ++ / WinRT动态绑定其Glyph值时无法正确显示字形

人气:359 发布:2022-09-22 标签: wpdevelop

问题描述

< FontIcon FontFamily =" Segoe MDL2 Assets" Glyph =" {x:Bind myGlyph}"> < / FontIcon> 

这会显示一堆矩形而不是正确的字形。但是如果我直接硬编码字形值,例如:&&#xE768;"它会正常工作。

我怀疑它与hstring的转换有关,必须碰巧绑定该值。

解决方案

确保实体"&# xE768;"仅在XAML字符串文字中有效。如果您想在C ++代码中指定相同的字形,请使用 L" \ xE768"

<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="{x:Bind myGlyph}"> </FontIcon>

This displays a bunch of rectangles instead of the correct glyph. But if I hard code the glyph value directly, for example: "&#xE768;" it will work correctly.

I suspect it has something to do with the conversion from hstring that has to happen to bind the value.

解决方案

Hi,

Make sure that the entity "&#xE768;" is valid only in XAML string literals. If you'd like to specify the same glyph in C++ code, useL"\xE768" .

776