Hello there,
Is there a way to set a property (like AutoFit=true for XamDataGrid WPF) in XamGrid in order to align the columns of the grid to fill the available space? I don't need the last 'blank' - 'pseudo-column' of the grid.
Thanks.
Hi,
Each Column has a Width property, you can set one of the Column's Width to "*" and that column fill the remaining space.
Or you can set all the Column's Width to "*" and they'll share the remaining space equally. We expose a ColumnWidth property on the XamGrid and ColumnLayout, and a Width Property on the Column.
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=xamGrid_Change_Column_Width_Settings.html
Hope this helps,
-SteveZ
The problem is that when I change the size of the columns (for example I increase very much the size of a column, such that it goes towards the margin of the xamGrid), the horizontal scrollbar appears. Definitely, this is not the behaviour of the autofit property I expect.
Please, tell me, is there a way to have an autofit behaviour in this case?
Hi Alin,
As soon as you resize a Column, its size is no longer a "star" size, and is instead a numeric value. So, if you had 5 columns in your grid that were all start sized, and you resize one of them, that column would get larger until the other 4 hit their minimum width (which by default is zero) and at that point a scrollbar would appear.
Another thing to note is that if the XamGrid is in container that gives it Infinite Width, star sized columns become normal "Auto" sized columns.
Thanks for your answer.
I understand why the Autofit behaviour is not achieved, but is there any other way to simulate it? I really need to have the Autofit WPF feature in my customized SL dataGrid and I think that maybe I could detect somehow when a column (or more) achieve their minimum width, i.e., when the scrollbar could appear, and to make invisible the scrollbar.
Is any possibility to achieve this or maybe another alternative?
Alin
HI Alin,
Perhaps you could use the ColumnResizing and ColumnResized events, in order to limit or adjust the sizing of your columns, to simulate the AutoFit behavior?
I used ColumnResizing in order to detect the moment when the resizing starts (because the event is fired only once) and based on this,when I am in "resizing mode" I have some logic in the MouseMove event' s handler, where I should detect the situation before appearing the scrollBar . The problem is : what should I do when this situation appears such that the resizing should not be allowed more?
I've tried to set each to column column.IsResizable = false for this, but if I keep dragging the column, without releasing the mouse, it will not have effect.
Please, tell me, do you have any idea about this issue?
Thanks,