Use dockpanel to stretch all children equally - xaml

What i would like to do is create a dockpanel with 4buttons and have the buttons be equal size .
However when i do this now, it formats the first 3 Buttons to fill the Contents of the button and the last button fills the remaining space.
Is there a way to have a control that i can put 4 buttons into and make them equal size. I have already seen the problems with StackPanel and from reading i thought dockpanel would fix this for me.
I know i can use setup a grid to fix this, but i was trying to find another solution.

I don't know which grid you know how to use, but I found the easiest solution is to use a UniformGrid with 1 row. That should fill all the buttons equally.

Related

VB Form Not Holding Format

In the design window, I have my controls formatted one way, but when I run my program, the formatting changes. The window looks larger and the digit button is no longer aligned. I have no clue how to fix this. I am taking an intro level course, so I can't fix this with code. When I wrote my first couple of programs, I didn't have an issue with resizing, but for the last two or three, they never hold their size.
My Program
the above issue please check the anchor tag of each control it should be Top left.
To hold the control position
1 Add panel control to form then dock it to form
2 Add the other
control it will hold the control position as well

VariableSizedWrapGrid does not size correctly if control size modified in code

I am creating a UWP app and I am using the VariableSizedWrapGrid control. I am binding the Width of the a ComboBox in the grid to it the ComboBox width resizes based on the entries in the list. ( I am using a simple property exposed through my view model.) When I had the items in a StackPanel with a Horizontal orientation it worked fine. See picture below
The challenge of course is that on a smaller screen I need the fields to wrap around. So I switched the StackPanel to a VariableSizedWrapGrid. However, when I do that, the Grid does not seem to be handling the resizing of the ComboBox correctly as I get what is shown below. (See the ComboBox is now cut off
Any suggestions on how to resolve this would be greatly appreciated.
You are using the wrong Panel for the job. The one you're looking for is a WrapPanel (which doesn't exist actually though), but there are some implementations available, eg.: http://codepaste.net/8gr5go

Draw border around controls on VBA Userform without using a Frame?

I am designing a VBA UserForm (in Excel, if it is relevant) and I would like some controls to be visually grouped together.. but when I put them in a frame, I am getting some undesired results (part of it has to do with the RefEdit control which seems to be particularly unhappy inside a frame).
Is there a way to draw a border around a group of controls on a form without putting them inside a Frame?
Use a label with the caption deleted and the border style set to fmBorderStyleSingle. It may appear on top of your other controls, so right click on it and select "send backwards" until it's behind your other controls.
The best way to do this would be to create the shape over where you need it to be. Drag highlight everything that you want on top of it, then right click and brink it all forwards. Then when you drag your shape back over the top it will in fact be underneath everthing else.
Hope that helps.
This worked for me and I was at first having the same issue where I had to choose to "Send Backward" up to 30 times per label in some cases. I found that hitting the Ctrl-K sends it to the back of all controls with one time hitting these keys.

two nearly identical usercontrols with different resize behavior

I have an application which has a tabcontrol that contains two tabpages. I have a custom made usercontrol docked to fill up each of those tabs. When I resize my main form to the minimum size allowed one tab resizes accordingly while the other seems to overflow the area and a couple ui items slip out of access/view.
One usercontrol was quite literally copied from the other and renamed and fields adjusted. The usercontrol size is the same between the two. Within the usercontrols there is a datagridview and a large panel full of textboxes and they have identical sizes and identical anchoring properties and even the same location coordinates.
I'm struggling to find a difference between the two but I really would like the resize behavior to match between the two usercontrols. I was wondering if anyone would have ideas of other things to check I did not mention here?
This should like very odd behavior.
There are a few things that I can think of to check:
1) Double-check that the user control is actually on the tab page itself and not on a different control, such as the tab or a common tab area (not sure of the tab control you are using; some controls have a common area that is available to all tabs).
2) Verify that the Dock property is indeed set to fill on the "bad" usercontrol.
3) Verify that you are not resizing or changing the Dock property on the bad usercontrol in code.
Found a minimum size on one of the usercontrols and that was the cause of my issue. Don't know how I didn't see it earlier.

FlowLayoutPanel not showing all contents?

Very weird situation going on with a FlowLayoutPanel...
I have been dynamically adding user controls to my panel. This user control has a height of 105. If I have my FlowLayoutPanelwidth to only show 1 "column" of controls, it will only display 296 of them. The rest of the controls are grayed out at the bottom of the flowlayoutpanel. If I widen the flp to allow 2 "columns" of controls, I can see 592 of them, with the remainder grayed out at the bottom. I have gone in and resized the user control to make it shorter in height, which works in some respects (i.e. it works when I have two columns, but not just 1), and can go forward with this work-around.
So, I guess my question is, why does the FlowLayoutPanel behave in this fashion? It seems (based on what I saw) that there is a limit to how much data the FLP will show at one time.
Your comment just reminded me that when you're adding many controls to any container it is a good idea to do this:
YourPanel.SuspendLayout();
// populate panel with controls
YourPanel.ResumeLayout(false);
This in effect stops the container (panel) from re-rendering itself every time you add a control until you're done adding controls. In the very least your panel creation will be smoother and faster. Not sure if this might fix your issue or avoid the need for a hack with PerformLayout.
If you look at your Form's designer file you will actually see this in action in the InitializeComponent function.