I'm experiencing a strange behavior, one for which I currently do not have an explanation or a solution and I'm hoping someone knows something about this.
So I have a simple Windows Forms application with a single button, which on button click will load a PresentationFramework
assembly:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Assembly.Load("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
}
}
Now when I have a custom scaling size (for instance 200%) set on my Windows 10 then on a button click the Form will get resized, see the following images.
- BEFORE CLICK:
- AFTER CLICK:
However this behavior does not occur when I'm using any of the provided scaling options (when I'm not using custom scaling):
I initially thought the problem is related to Form.AutoScaleMode
, but it doesn't seem to be. Also I'm unable to observe any changed value in Form
object.
I am not sure that I completely understand your issue here but you could try to add the following attribute to your AssemblyInfo
.cs file (you'll find it under the Properties node in the Solution Explorer in Visual Studio):
[assembly: System.Windows.Media.DisableDpiAwareness]
This will allow the application to disable to use dots per inch (dpi) awareness for all user interface elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With