What is the WPF version of Control.ScaleControl
?
i am trying to honor the user's font preference by setting the font to the IconTitleFont:
private void ApplyUserFontPreferences()
{
this.FontFamily = SystemFonts.IconFontFamily;
this.FontSize = SystemFonts.IconFontSize;
this.FontStyle = SystemFonts.IconFontStyle;
this.FontWeight = SystemFonts.IconFontWeight;
}
Unlike WinForms, the contents of the form are not scaled with the font change:
Before
After (bad)
In reality all controls on the form (including the size of buttons, the width of listview columns, etc) should scale to match the new layout:
After (good)
Since WPF doesn't (unlike WinForms) respond to font sizes changes, i was going to workaround the issue by trying to scale the WPF form myself, using a hypothetical WPF version of ScaleControl
:
private void ApplyUserFontPreferences()
{
Double scaleFactor = (SystemFonts.IconFontSize / this.FontSize); //i.e. new / old
this.ScaleControl(scaleFactor); //doesn't exist
this.FontFamily = SystemFonts.IconFontFamily;
// this.FontSize = SystemFonts.IconFontSize;
this.FontStyle = SystemFonts.IconFontStyle;
this.FontWeight = SystemFonts.IconFontWeight;
}
Another example of wanting to scale a control (and all child controls) is when i need to scale a control (and all child controls) to fit in a given size. In this case i don't want to scale an entire form, i only want to scale a particular control.