Hello
Im using Infragistics for WPF 12.2.20122.2202
Very simple scenario: I have a view and want to have XamGrid that is not stretched to the parent container - instead - it should be vertically alignment to the top.
The problem is that, whatever I set for the VerticalAlignment, the content seems to be always stretched
(how I know this, well - if there are many columns, the HorizontalScrollBar appears on the very bottom. Instead - it should appear just under the last row within a grid).
Is there any way to achieve this?
Hi,
The most straight-forward approach is to give the grid a specific height.
There isn't any specific property but if you put the xamGrid in a stackpanel you can use the VerticalAlignment of Top and the grid will only use the vertical space it needs and the horizontal scrollbar will follow immediately at the bottom of the last row. The drawback is that the vertical scrolling is lost because the grid has no idea how much vertical space is required. And if you have a lot of rows they may be clipped off. That's caused by putting the control in a stackpanel. So you may still need to give the grid a specific height.
Let me know if either of these options helps you.
I was wondering if my suggestions resolved your question. Please let me know if you have further questions.
Thank you for a reply.
Is this the only solution ? If I place the XamGrid inside a stackpanel .. wouldn't I loose virtualization?
In other words: is it not possible to have XamGrid VerticalAlignment to Top inside .. a DockPanel ?
I would not like to hardcode Height, instead - let the XamGrid take as much space as it's content has.
Thanks, that will work.
I didn't mean to recommend that you use a stackpanel because it will indeed cause you to loose virtualization. I understood that there wouldn’t be many rows in the data, otherwise, you wouldn’t notice the scrollbar being separated from the datarows.
Let me add a link to some documentation concerning the XamGrid and virtualization to help clarify.http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/xamGrid_Virtualization.htmlIn the section described as "Disabling Virtualization", it says "Virtualization is always on when you set the Height and Width properties of XamGrid or its containing element."
At some point you would need to assign the height of the control or the container in order for the grid to not stretch/use the maximum space, putting the horizontal scroll bar at the bottom of the window or container.
By setting a height, you could put the horizontal scroll bar just below a line of data and using the vertical scroll bar to access the remaining data rows.
I guess another option for the original question might be to use ColumnWidth="*", which causes the columns to take all of the horizontal space available, eliminating the horizontal scrollbar. If needed, you can use ColumnWidth on the xamGrid and by setting Width property on a column(s) to relative sizing force column sizing to be proportional. This can force the scrollbar to appear so you’d be back at the same question, still needing a height.