Unfortunately I can't provide screenshots for comparison now, since I'm unable to use Aero here at work, but I'm having the following problem:
I'm creating a small WPF application. My main window is not resizable, and the sizes and positions of everything inside are fixed. Everything works fine here using some pre-defined theme (it's "Windows Classic" most likely). Once I run the exe at home though - with Aero enabled - the border size is way bigger, but the actual total window size stays the same it seems to me. So the borders go "into" my window, shrinking the actual usable space and thus some of my controls are overlapped by the borders and it looks asymmetrical.
What can I do about this, if anything? Is there some option to make the borders be attached "outside" my used window space?
Edit: Here is an uploaded image of the Aero version. I hope the problem can be seen. (It's at the bottom)
In my opinion a static size is a bad way in wpf.
There are different solutions:
1. make your window a bit heigher or
2. reduce the margin between your used content elements or
2. use a dynamic size of your content. A grid with rowdefinitions set to "X*" where x is the height in propotion to total height of your content.
But im not sure ... you use a style in your app or is the style directly set into element? If you use a xaml stysle file, is it possible the style overrides your set position or margin properties?
Related
I`m exploring the navigationview control for uwp projects. I noticed that when I resize the window to a smaller size the menu changes to compact mode and, if the the window is small enough it overlays over the right page window rather than pushing it to the side.
I want to change the navigationview control to have this behavior by default without having to resize the window to a smaller size. The goal is to have the page window with the most space available possible.
I tried some properties but none worked, any pointers how to change this default behavior(Overlay and always in compact mode)?
you should use the latest NavigationView by winui library, and in this control you have a property PaneDisplayMode, explore values of this property and you can know what exactly you want. In your scenario you want the left pane to completely disappear and overlay then you can try LeftMinimal but if you want it in compact mode which shows only Icons then you can use LeftCompact
You can try to confugure the CompactModeThresholdWidth and ExpandedModeThresholdWidth properties of NavigationView. These properties will get or set the minimum window width at which the NavigationView enters Compact or Expanded display mode.
<NavigationView CompactModeThresholdWidth="280" ExpandedModeThresholdWidth="2800"/>
You can set the width value base on your requirement. For example, if you want the NavigationView alway in Compact Mode, you can use above code with any CompactModeThresholdWidth property value smaller than the minimum default UWP app window width and the ExpandedModeThresholdWidth property value larger than the maximum window width.
I'm using Windows 10, Visual Studio 2017 and writing a C# Windows Form Application.
I have a windows form application that I am writing (partly in an attempt to get better at writing such things). I have designed my form nicely, with everything spaced and sized properly, but when I press F5 to start the form to debug it, I find that it loads at about 75% the size of the one I see in the designer.
This resizing seems a bit hit and miss, with buttons that were previously aligned no longer being so, and text no longer fitting in its spaces (see pic - the top part shows the designer and the bottom shows the actual form being run).
I would like to have the designer accurately reflect the final look of the form - does anyone know what is going on or how to avoid the problem? Everything I have looked at on the web talks about choosing to resize the form, not this enforced resize!
Have you changed the whole form font size? By default WinForms designer set
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
try changing the AutoScaleMode and see what happens.
I've experienced similar WinForms designer issues when the default Font (in the form property) size is not 8,25pt. I dont't know why but seems related to desktop and/or screen configuration. Not sure but some weird behaviours could be bugs (WinForms is now quite old...).
AutoScaleMode.Font means that form scaling is based on font size. So trying changing different font settings can solve the problem.
hope this help
When designing the form, the form automatically sets the anchor points to Top Left. You will have to set the anchor points to your form.
The anchor style works like this. On a control if you set anchor points to:
Top/Right then the control stays in the Top Right.
Top/Left then the control stays in the Top Left. Bottom/Right then the control stays in bottom right. Bottom/Left then the control stays in bottom left.
Top then it stays at the top.
Bottom then it stays in the bottom.
Left then it stays in the Left.
Right then it stays in the right.
Top/bottom stretches top to bottom.
Left/Right stretches left to right.
Now when you anchor a control to any of those combinations they will stay in that location when form is maximized. Controls can anchor to each other as well.
I hope this helps.
Also here is a tutorial I did on this.:
https://youtu.be/wlZ6pt79v1E
accurately reflect the final look of the form
Your form's appearance is mostly decided by the end user. Font, size, colour, scale, contrast... all these things are under the users control, not yours.
Consider using split panels, and maybe some flow panels. Get used to 'randomly sizing' the form when you think you've finished designing, to see how it reacts to being the 'wrong size'. Someone will find a way to shrink or grow your form, and handling that gracefully is easier than enforcing a view.
I am attempting to create a Windows Forms Application that will have components that scale when the window is being resized. I am running into issues with the Form when attempting to resize it when the application is running. First of all, this is what it looks like in the editor at its Minimum Size:
Then I stretch it out at run time and it is even on both sides (after tinkering with the Fixed-Splitter position:
I run into more problems when attempting to put List Boxes in the blue and red panels. In design:
Stretched:
I want the list boxes to nicely fill most of the width of each side, but when I attempt to use the Anchor tags it gets messed up.
So to sum up: Why is the designer all asymmetrical compared to the finished product and how do I make the List Boxes fit and scale in width when the window is resized?
I am using VS17 if that helps! Thanks!
The anchors was always (I don't know why) littlebit broken. Use the composition of nested Panels and use the Dock and Padding properties instead of anchros.
When you set the size of a windows form, ie;
Form1.Size = new System.Drawing.Size(700, 500);
Does this include the border which windows puts around the form? Because I have added images (via pictureBoxes) which are 700x500 to my form, and they have been cut off by the border.
Also: When I say the border, I mean the default windows border which you can drag the edges of to resize it, as well as contain the red X, Minimize, and Maximize buttons.
That depends, you'll get a different size when you target .NET 4.5 for example. The border is always included but you don't really know how much of the border is included. An issue with the fat borders you get with Aero and the skinny ones you get in XP.
It is almost always the wrong thing to do. You always want to assign the ClientSize property instead. Important, it doesn't include the borders so you can be sure that controls still fit.
And hard-coding the size is always wrong as well. Your form will be rescaled, depending on the video adapter's dots-per-inch setting. The larger the DPI setting, the bigger the form needs to be to still fit its content. So the correct statement ought to resemble this:
this.ClientSize = new Size(PictureBox3.Right, PictureBox3.Bottom);
On the assumption that "PictureBox3" is the control in the far right-bottom corner that you want to keep visible. This statement needs to appear in the Load event handler to ensure that rescaling was done, it can't work in the constructor. One of the very few good reasons to use the Load event.
I've been looking around for quite a while now and can't really find a complete example and may just be missing some small element.
I'm trying to create a WPF Theme/Style/ControlTemplate/etc for a WINDOW. The one where Window borders set to none, allow transparency, and background set to transparent. So, yes, this means I have to define the buttons, borders, background, etc as I've found in other samples.
I've found a few links that utilize (and have that working) through the use of a "Thumb" control anchored to the lower-right.
What I'm missing is how to do resize from the respective borders that are constructed within the new ControlTemplate of the theme. I do have the buttons working for things like min/max/restore/close, but can't quite get how to handle the resize.
Thanks
I've used this link once. If I remember well, the resize border could be set to work as an arbitrary amount of pixels from the sides of the Window, even without a "real" border element.
http://www.codeproject.com/Articles/131515/WPF-Custom-Chrome-Library