如何在按钮中使用自定义字体作为LightSwitch应用程序(Silverlight)的自定义控件

时间:2018-10-10 12:15:16

标签: silverlight visual-studio-lightswitch

在我维护的旧版LightSwitch应用中,我试图通过自定义字体在Button中使用图标。

我尝试了互联网上建议的几种解决方案(请参阅下文),但没有任何效果。而且测试它(运行应用程序并检查)的周期也不是很有效。

添加的ttf的设置:

Location = DesktopClient项目的根
构建操作=资源
复制到Ouput目录=如果更新则复制

var button = new Button {
                    Content = new TextBlock { Text = "\uE768", FontFamily = new FontFamily("MyApp.DesktopClient;Component/SegMDL2.ttf#Segoe MDL2 Assets") }, 
                    Command = new Command<int>(_myAction)};


位置= DesktopClient项目的根
建立动作=内容
复制到Ouput目录=如果更新则复制

var button = new Button {
                    Content = new TextBlock { Text = "\uE768", FontFamily = new FontFamily("./SegMDL2.ttf#Segoe MDL2 Assets") }, 
                    Command = new Command<int>(_myAction)};


请注意,对于我尝试过的文本:"\uE768""&#xE768;"

更新

检查时:

var uri = new Uri("MyApp.DesktopClient;Component/SegMDL2.ttf", UriKind.Relative);
var resource = System.Windows.Application.GetResourceStream(uri);

resource不为空。

0 个答案:

没有答案