I've created an WPF application that should run on Win7 and Win10.
It displays some ListBoxes and I designed it on Win7 - all looks well!
Now I run it on Win10 and it looks very wiered. The ListBoxItems are larger than the ones on Win7 and so they display scrollbars where no scrollbar should be.
After some testing with snoop I see that the Border and the Padding of the ListBoxItem has changed.
In Win7: Border="0,0,0,0" Padding="2,0,0,0"
In Win10: Border="1,1,1,1" Padding="4,1,4,1"
Were does this come from?
How can I prevent such errors?
It couldn't be that I must set all values of all WPF Elements to an explicit default value, just to be sure they stay the same under Win10.
I'm thinking this could be something to do with the Frameworks used, I tested below with Framework 3.5 and Framework 4.6.2. Is this the padding difference you are seeing from Windows 7 to Windows 10?
I checked using snoop and see the padding differences you mentioned, padding="2,0,0,0" changed to "4,1,4,1" Maybe you could set the properties of your application to only use a lower Target Framework that is in your Windows 7 machine?
How to change Target Frameworks:
https://msdn.microsoft.com/en-us/library/bb398202.aspx
Related
We have an old project that is designed using VS2005 and WinForms. Everything works perfectly on Windows XP, but when I open the designer on Windows 7, everything breaks down.
The controls get sized to random size and some of them dissappear (or are moved to random coordinates).
What can we do to solve this issue? Should we switch to VS2008?
A newer version of VS should help, but i'd be surprised if this can't be fixed in 2005.
Try commenting everything out in the method where initializeComponent runs, or any properties that set UI change. You should find it easy enough, it's a method that has long lists of calls against the controls on the form.
The problem was that we used TableLayoutPanel inside a GroupBox and not on the form. When we added the TableLayoutPanel on the form and moved the GroupBox into it, the designer stays ok.
We have a couple of winforms applications that host a bunch of icons in a ListView control as a handy quick launch down the side of the applications. We also have "XP visual styles" enabled in the project build options for both which works great for Windows XP, but we've had someone highlight that the items in the control are (roughly) twice as wide in one application as the other (normal) when both are run under Windows 7.
As far as I can see in code, both ListViews are added to their respective forms using the windows forms designer, and there doesn't appear to be anything fiddling with the width of the labels (etc.)
I'm a little confused why the two applications/ListViews are behaving differently, and also why there doesn't seem to be anything I can do to affect the width of the items in the ListView? What have I missed when checking for differences between the "working" scenario and the "non-working" scenario?
It appears that setting the StateImageList property causes this (even if it is the same image list as used for the normal icons)
I am developing a Windows Forms application using VS2008 on Windows Vista. I tried to run my application on Windows XP the other day, and everything on GUI was messed up. I realized that I developed the application using 120 Dpi setting on Windows Vista and my XP was set to 96 dpi.
My application has several UserControls and all of them shrinks even in the Visual Studio itself if I change my DPI to 96. I am sure a lot of people are using Visual Studio in high DPIs these days. So how can make sure that my GUI does not get messed up both in Visual Studio and runtime?
EDIT: I have read couple articles on this issue and I learned that I should be setting AutoScaleMode to None. However, this still does not prevent my labels to adapt new DPI settings enforced by the operating system. I need a way to prevent my labels to grow/shrink because other GUI elements have fix sizes.
It has been a while since I worked on this issue, but try setting AutoSize = False. In addition, UseCompatibleTextRendering = True might help.
This is a rather old question, but I want to share my solution/opinion. I ran into a similar problem recently. Actually, I want Visual Studio to keep my WinForms as they are, but them to scale at runtime. I found no consistent summary on how to correctly do that. After some reading and experimenting I came to this solution:
Keep the Form’s AutoScaleMode = Font.
Set in your Forms Designer: Font = MS Sans; 11px
In the Forms Ctor, after InitializeComponent, set: Font = SystemFonts.DefaultFont
Enable DPI-Awareness, either through a manifest or by API function SetProcessDPIAwareness
Since AutoScaleMode remains active, all DPI-changing magic works, even per-monitor DPI awareness. What remains, is designing Forms in a way scaling works nicely.
I wrote the details on my Blog: http://www.sgrottel.de/?p=1581&lang=en
I think I'm missing something fundamental. Please tell me what it is, if you can.
I have developed a little C++ WinForms app using VS2008. So it is built using .NET 3.5 SP1.
My development box is Win7, if that matters.
The default value of UseCompatibleTextRendering property in WinForms controls is false in this version of VStudio. And this should not matter to me, I don't think. I don't have any custom-drawn
text or controls.
The app looks good running on my Win7 box.
If I package it up (dragging along .NET 3.5) and install it on one of our WinXP desktops, the buttons and labels don't look good; the text is chopped off in them.
If I set UseCompatibleTextRendering to true and then run it on the XP boxes, the text fits into the
buttons and labels.
My question is: Why? The installation puts .Net 3.5 on the XP boxes, so the app should be able to find and use the right version of WinForms, right?
I should note that before I put my app + .NET 3.5 on these boxes, they have no .NET at all. They do not get automatic Microsoft updates; our IT guy gates the patches and upgrades.
[ This sort of thing has happened before with apps I create.. they look/work great on the Engineering machines, because we maintain those and they mostly have up-to-date stuff. When they are run on the corporate boxes, they usually don't run and need the VCredist installed. ]
Back to the question at hand: The text looks better with the UseCompatibleTextRendering set to false, so I'd rather keep it that way, if I can. I'd like to understand what might be missing on those XP boxes that is making the text not fit.
Thanks
S
It is probably a scaling problem, the XP machine may have a different video adapter DPI setting or a different system font size. Scaling is affected by the form's AutoScaleMode and whether or not they "inherit" the container control's Font property. Which it does if the Font property isn't bold in the Properties window.
One quick way to check if scaling works property in your Form:
protected:
virtual void OnLoad(EventArgs^ e) override {
this->Font = gcnew System::Drawing::Font(this->Font->FontFamily,
this->Font->SizeInPoints * 125 / 96);
}
That scales it up. It probably gets scaled down on the XP machine, use 96/125.
I have been testing my .NET windows applications with Mono on Ubuntu and noticed that my controls are always stretched in height. Width wise appears to be fine. I have a stack of 5 comboboxes that fit nicely within a panel, but with Mono on Ubuntu the comboxes are too tall and the last comboxbox is pushed into the boundary of the panel. Anybody know why this is happening?
You can check and see if you are using AutoScaling by accident:
http://www.mono-project.com/FAQ:_WinForms
Or someone pointed me to a really weird cause of this a couple of days ago, having Thai fonts installed on Ubuntu:
https://bugs.launchpad.net/ubuntu/+source/fontconfig/+bug/539008