在我维护的旧版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"
和""
更新
检查时:
var uri = new Uri("MyApp.DesktopClient;Component/SegMDL2.ttf", UriKind.Relative);
var resource = System.Windows.Application.GetResourceStream(uri);
resource
不为空。