VariableSizedWrapGrid does not size correctly if control size modified in code - xaml

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

Related

Animate TranslateTransform on GridViewItem

I have a series of items in a GridView.
I want to animate the TranslateTransform of a GridViewItem so that it is outside the boundary of the GridView. When I do, it is clipped. Is this type of transform possible?
Sadly, I don't think so. I had to do something similar a while ago and it turns out that the template of a GriView (and ListView, ListBox, etc...) contains a ScrollViewer control. The thing about the ScrollViewer controls is that they MUST define a clipped viewport to give the user the impression of scrolling. In fact, if you were to decompile the ScrollViewer control, you can see that it hard codes the clipped bounds, so you cant even change the template or style.
Things may have changed since I looked into this, and my investigations where on WPF not XAML in Windows 8, but I dont think that it would have changed based on your description of the issue.
Here is a SO question in relation to this topic: WPF clipping even when no clipping is desired - how to turn it off?

Is preparing Windows 8 XAML HubPages from several GridViews inside ScrollViewer the good approach?

I'd like to get the effect visible on the picture:
I don't think it is. A GridView already has a ScrollViewer in itself, so multiple of them does not make sense. I would try to use a single GridView with GroupStyleSelector/ItemContainerStyleSelector/ItemTemplateSelector implementations and DataTemplates to define each item. A less dynamic version might just be a ScrollViewer with Style set to HorizontalScrollViewerStyle, a horizontal StackPanel and a few VariableSizedWrapGrids - if you bind the GridView to some groups or other panels to define the content.
This looks like a good sample based on the description (though the images seem to be missing for me).

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.

In VB.NET, can we draw empty lines instead of blank area in non existent row of datagrid?

EDITED:
I think we can just draw an image that resemble the grid using this article : drawing in a datagridview Currently creating a way to make the image drawn in tile mode. :)
Each time I develop a datacentric application using VB.NET regardless of how much the data displayed in the datagrid, I always want the grid to display full row of empty data, not just blank panel.
Can we achieve this using VB.NET design time property?
And also, we must not trigger the display of vertical scrollbar this way.. :)
Thanks
You might try doing a screen capture of the dgv when it is full of blank lines and use that as your background. However, you'll have a problem with the vertical lines if they resize the columns. In your picture you don't have any vertical lines so if you don't need them then just erase them and your problem is solved.
There's also the option of using the Virtual Mode. When you set that property to true then you can set the number of visible rows, but you are responsible for telling the dgv what each individual cell is supposed to contain: http://msdn.microsoft.com/en-us/library/2b177d6d.aspx
Or you can just add extra blank rows to whatever datasource you are setting your DGV to.
Use the ScrollBars property to turn the vertical scroll bar off.

winforms - usercontrol with dockstyle fill not correct size during form load

My main form has two panels, left docked and right docked. The right side panel has two child panels with top dock and bottom dock settings. The usercontrol is added to the right side top panel.
My usercontrol has a panel and a label. The panel is anchored on all 4 sides, the label is anchored on all except the bottom. At runtime I create this usercontrol and set it to dockstyle=fill and then I add it to my top right panel.
With everything set to "fill" I expect that when I add my usercontrol to the panel it will take on the appropriate width and height and pass that info to the child controls (labels) inside of my usercontrol.
My problem is that this stretching of the size does not happen when I create my objects during the Load event on my usercontrol. Even though initializecomponent has ran for the usercontrol the panel inside of it (4 corners anchored) has not taken the x/y values of the available space. As a result my usercontrol shows up about 50% of the width I want.
Lets say that instead of creating objects during usercontrol load that I instead start a timer and have the timer call my create routine when it raises the tick event. When I do things like this my objects are created with the full width/height that I expect. The only issue here is that this causes a delay in my interface.
Can someone help explain this behavior? My mainform is calling a "load gui" routine which is instantiating usercontrols, setting panel sizes, and then adding usercontrols to those panels. This particular user control is the last to load into the panels from that load gui routine so it does not make sense that the parent panel width/height would not be known yet. This is one of my first apps where I am purposely trying to use dockstyle=fill to keep things consistent across different main form sizes without writing all the extra size_changed code handlers. I'm sure this one is easy to work around once I know where the problem lies.
Thanks for any help provided!
this turned out to be a padding issue on the parent usercontrol. I also had to allow a bit of wiggle room to make sure that the controls didn't overflow the panel so I did a parent.width - 15 and that along with the padding made everything work much better.