Hi,
I change visibility of one of fields in Grid:
field.Visibility = Visibility.Visible;
And to add new field at last position :
var lastVisibleField = MainGrid.Grid.FieldLayouts.First().Fields.Where(f=>f.Visibility == Visibility.Visible).OrderByDescending(f=>f.ActualPosition.Column).First();
field.ActualPosition = new FieldPosition(lastVisibleField.ActualPosition.Column + 1, field.ActualPosition.Row,field.ActualPosition.ColumnSpan,field.ActualPosition.RowSpan);
To this moment code works ok.
but when I try to scroll to this new field it not works as should. It is visible but view scroll to position it was last time.
MainGrid.Grid.BringCellIntoView((MainGrid.Grid.Records[0] as DataRecord).Cells[field.Index])
When I use last visible field it scroll to it, scroll works but it is last but one .
MainGrid.Grid.BringCellIntoView((MainGrid.Grid.Records[0] as DataRecord).Cells[lastVisibleField .Index])
Why after changing actual position of the field I can not scroll to it? I am missed something? Should I change other field property?
Hello Lukasz,
Thank you for contacting Infragistics.
I have been looking into your post and I believe the issue you are experiencing is caused by the fact you are using the Index property of the field when calling BringCellIntoView method. In your scenario you need to use the ActualPosition property which returns the resolved position of the field in the field layout. The difference between this property and the Index, Column, Row, ColumnSpan and RowSpan properties is that these properties specify the initial or default position information of the field whereas ActualPosition specifies the actual or current position information of the field.
I am attaching a sample application for your reference where I’m using the field’s ActualPosition.Column and the field is successfully scrolled into view.
If you have any further questions on the matter do not hesitate to contact us.
HI,
The problem was too short period of time between changing ActualPosition of the field and use BringCellIntoView on this field. Ui don't update itself and scroll to older position of the field.
So I subscribe to event CellsInViewChanged before change ActualPosition and use BringCellIntoView in this event. Now it works.:
_bringToFrontField = selectedField;Grid.CellsInViewChanged += Grid_CellsInViewChanged;_bringToFrontField .ActualPosition = new FieldPosition(lastVisibleField.ActualPosition.Column + 1, field.ActualPosition.Row,field.ActualPosition.ColumnSpan,field.ActualPosition.RowSpan);
void Grid_CellsInViewChanged(object sender, CellsInViewChangedEventArgs e){ MainGrid.Grid.BringCellIntoView((MainGrid.Grid.Records[0] as DataRecord).Cells[(_bringToFrontField as Field).Index])
Grid.CellsInViewChanged -= Grid_CellsInViewChanged;}
Hello lucasz,
Thank you for your feedback. I am very glad that you have manage to resolve your issue and I believe that other community members may benefit from this as well.
If you require any further assistance on the matter, please do not hesitate to let me know.