Hi,
if one fixes columns in the near end of the grid, the FieldLayout becomes "explicit". Then the code:
DataGrid.FieldLayouts[0].Fields.Insert(1, field); works in a different way, than before the fixing. The field is added always at the end of the Layout and the ActualPosition is not anymore the given index (1).
How can one check if the Layout is Explicit, so that one can take measures and manipulate the field.ActualPosition himself? Is there a Property which tells me, whether the Layout is "explicit" or not?
Regards,
George
Hello George,
Thank you for your post!
I have been looking into question. The layout of the field becomes explicit when the end user moves, fixes, hides a field, etc. When one of these operations is made you can use the following code snippet for inserting the Field.
DataGrid.FieldLayouts[0].Fields.Insert(1, field);
field.ActualPosition = new FieldPosition(1, 0, 1, 1);
foreach(var f in DataGrid.FieldLayouts[0].Fields)
{
if (f != field && f.ActualPosition.Column >= 1)
var pos = f.ActualPosition;
f.ActualPosition = new FieldPosition(pos.Column + 1,
pos.Row, pos.ColumnSpan, pos.RowSpan);
}
Please do not hesitate to let me know if you have any further questions on this matter.
Hi Gergana,
Ofcourse I don't want to follow and care for all the events you mentioned above. The scenario is as follows:
At some point in Runtime I need to add a Column at a specific Position in the Layout. I don't know the history of the XamDataGrid at this time. If some Fields were reordered, hidden, fixed or whatever I don't know. So I have to find out.
That's why - again the same question:
How to check if a FieldLayout is explicit or not at a specific moment.
if(FieldLayout is Explicit -> how to do this???)