Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1590
Questions on ActualPosition and grid.FieldLayouts[0].Fields collection.
posted

Hi.

I have 2 questions regarding columns positions/reordering.

1)During my analyzing the column's field.ActualPosition.Column property I've found its strange  behaviour if FieldLayout contains hidden columns (columns with column.Visibility  = Visibility.Collapsed)

I've attached the simple application, that contains XamDataGrid bound with BindToSampleData="True".

Steps to reproduce:

I have hidden the first two columns:  "name" and "department" in Loaded event handler( it doesn't matter where you will hide these columns, you would do this in OnButtonClick event handler, for example). Then I displayed the field.ActualPosition.Column for each columns(after click on the corresponding button):



As you can see the result is very strange. It sounds like the field.ActualPosition.Column try to take into account whether column is hidden or not. But this is very ugly that the columns that are placed on the different positions have the same ActualPositions values. Please, comment on this.

2) I moved any column via drag&drop on other position. But grid.FieldLayouts[0].Fields collection has not changed and index of column being moved also not changed. But if you will use move grid.FieldLayouts[0].Fields.Move method the grid.FieldLayouts[0].Fields collection will be repositioned and columns on UI also will be reordered as per parameters of grid.FieldLayouts[0].Fields.Move method. You can check what I described here in the sample attached.


Thanks, Alex.

ActualPositionIssuesSample.zip