I have an VSTO Outlook Add-in which shows a custom task pane (ctp). This ctp embeds a usercontrol which in turn contains an elementhost. The elementhost hosts an WPF user control.
At Add-in startup I create the ctp and I set it a fixed height, e.g. 120 points. I have noticed that depending on the screen resolution the ctp height gets smaller or bigger.
So I would like to know if there is a way to set the ctp height according to the current screen resolution so it does not get smaller or bigger.
For example some formula:
ctp.Height = Default_Height * Y_Scaling_Factor
I have tried setting the autoscalemode to font and dpi and it does not work.
You need to set the AutoScaleMode property to
Noneif you don't want to get the container scaled according to the screen resolution.The
AutoScaleModeproperty specifies the current automatic scaling mode of this control. Scaling byFontis useful if you want to have a control or form stretch or shrink according to the size of the fonts in the operating system, and should be used when the absolute size of the control or form does not matter. Scaling byDpiis useful when you want to size a control or form relative to the screen. For example, you may want to use dots per inch (DPI) scaling on a control displaying a chart or other graphic so that it always occupies a certain percentage of the screen.For more information about automatic scaling, see Automatic Scaling in Windows Forms.
Also you may take a look at the AutoSize and AutoSizeMode properties that resize the form according to the setting of
AutoSizeMode.