Example #1
0
        private void WinFormsHost_DpiChanged(object sender, DpiChangedEventArgs e)
        {
            System.Windows.Forms.Control control = ((WindowsFormsHost)sender).Child;

            float scaleFactor = (float)(e.NewDpi.PixelsPerDip / e.OldDpi.PixelsPerDip);

            // This method recursively scales all child Controls.
            control.Scale(new System.Drawing.SizeF(scaleFactor, scaleFactor));;

            // Scale the root control's font
            ScaleFont(control, scaleFactor);

            // Recursively scale the font of controls with different fonts
            ScaleFontRecursively(control, scaleFactor);
        }