Style后台设置
创建新样式
/// <summary>
/// 创建新样式
/// </summary>
/// <param name="type">控件类型</param>
/// <param name="style">基础样式</param>
/// <param name="family">字体名称</param>
/// <returns></returns>
Style CreateStyle(Type type, Style style, FontFamily family)
{
var rslt = new Style(type, style);
rslt.Setters.Add(new Setter(FontFamilyProperty, family));
rslt.Setters.Add(new Setter(FontSizeProperty, (double)24));
return rslt;
}
获取系统所有字体
var fonts = new InstalledFontCollection();
var rslt = fonts.Families.Select(s => s.Name).ToList();
var family = new FontFamily(rslt[0]);
gridTest.Style = CreateStyle(gridTest.GetType(), gridTest.Style, family);
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步