Hi,
Is there any way to change the field position by code in the field layout?.
The ActualPosition property is read only and changing the Column property has not effect... I guess that the ActualPosition property as priority over the Column property.
Anyone?
Thanks.
I will create a support case on your behalf and link it to this issue. There is a way around this. The Column, Row properties are not take into consideration if the user has moved,fixed, loaded customizations. That is why you have to call the ClearCustomizations() method. Here is one option that you have:
xamDataGrid1.ClearCustomizations(
CustomizationType.FieldPosition);
FieldCollection fields = xamDataGrid1.FieldLayouts[0].Fields;
fields.Move(0, 3);
Regards,Alex.
OK, Thanks. I hope there is some kind of workaround.
What I was saying is that you can reproduce the problem by either changing a column's position by Drag&Drop OR calling LoadCustomizations.
Actually, I can reproduce this without calling the LoadCustomizations method. I believe this could be a possible issue. I am going to investigate this and follow-up here.
Regards,
Alex.
I think I found out what the problem is. You can reproduce it in your sample as well.
As soon as you move a column by drag&drop, you can't change the position of a field anymore programmatically.
In my application, I allow to hide a column by right clicking on the header. When the user tries to bring it back, I try to move it at the end of the FieldCollection. Since it doesn't work, I guess that setting the Visibility flag to collapsed on a field of the FieldLayout produces the same kind of problem.
It doesn't work because of a call to LoadCustomizations. I can hide columns and I will still be able to move columns around by code, but I soon as I call LoadCustomizations or if I move a column by drag&drop, I can't do it anymore.
The sample does work.. I'll try to find out what's wrong with my specific usage and let you know.