【发布时间】:2015-02-23 15:10:50
【问题描述】:
我正在尝试制作一个带有图标的网格。我将图标的字符串表示形式存储在数据库中,并尝试通过绑定到我的视图模型上的 Icon 属性(字符串)在 GridHub 中显示这些图标。
当我使用这个 xaml 时,我得到了显示在网格中的实际文本
<TextBlock Text="{Binding Icon}"
FontFamily="Segoe UI Symbol"
FontSize="100"
TextAlignment="Center"
VerticalAlignment="Top"
Foreground="DarkGray"
AutomationProperties.Name="Some Label"/>
但这会按预期显示图标
<TextBlock Text=""
FontFamily="Segoe UI Symbol"
FontSize="100"
TextAlignment="Center"
VerticalAlignment="Top"
Foreground="DarkGray"
AutomationProperties.Name="Some Label"/>
我的模型看起来像:
public class PermissionGroup
{
/// <summary>
/// The unique identifier for the group.
/// </summary>
public string PermissionGroupId { get; set; }
/// <summary>
/// The name of the group
/// </summary>
public string Name { get; set; }
/// <summary>
/// The page associated with the permission group
/// </summary>
public string PageName { get; set; }
/// <summary>
/// The icon that will be shown on the PermissionHub page
/// </summary>
public string Icon { get; set; }
/// <summary>
/// A description of the permissions in the group
/// </summary>
public string Description { get; set; }
/// <summary>
/// The permissions associated with this permission group
/// </summary>
public List<Permission> Permissions { get; set; }
}
我的视图模型只包含这些对象的列表。
在我的数据库中,我尝试存储以下内容:
&#xE1D4;- \uE1D4(必须转义才能进入数据库)
- 57812(
char.Parse("\uE1D4")的结果)
这些都没有导致图标正确显示!
【问题讨论】:
标签: c# xaml windows-8.1