C# - WPF Font von WinForms Fontprivate void setFont(UIElement element, System.Drawing.Font systemFont)
{
TextBlock tbElement = (element as TextBlock);
Label lbElement = (element as Label);
if (tbElement != null)
{
tbElement.FontFamily = new System.Windows.Media.FontFamily(systemFont.Name);
tbElement.FontSize = systemFont.Size;
tbElement.FontStretch = FontStretches.Normal;
tbElement.FontStyle = (systemFont.Style == System.Drawing.FontStyle.Italic ? FontStyles.Italic : FontStyles.Normal);
tbElement.FontWeight = (systemFont.Style == System.Drawing.FontStyle.Bold ? FontWeights.Bold : FontWeights.Normal);
}
else if (lbElement != null)
{
lbElement.FontFamily = new System.Windows.Media.FontFamily(systemFont.Name);
lbElement.FontSize = systemFont.Size;
lbElement.FontStretch = FontStretches.Normal;
lbElement.FontStyle = (systemFont.Style == System.Drawing.FontStyle.Italic ? FontStyles.Italic : FontStyles.Normal);
lbElement.FontWeight = (systemFont.Style == System.Drawing.FontStyle.Bold ? FontWeights.Bold : FontWeights.Normal);
}
}