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
2090
xamDataGrid: Position SelectedItem on the top of the grid
posted

Hello,

I am searching for some time how to position a SelectedItem in specific position.I saw several positings on that subject. Some solution did reorder the underlying binding, others skip with the scrollbar to position the SelectedItem.

Is there a method to put the SelectedItem as the first record in a xamDataGrid?

Thanks

Niko

  • 34810
    Offline posted

    Hello Niko,

    Currently there does not exist a method to place the SelectedItem as the very first record in the XamDataGrid without either reordering the underlying bound data source collection or moving the scroll bar to essentially position the SelectedItem at the "top" of the grid.

    If you are going to go with the scroll-bar route, know that there does exist a BringRecordIntoView method as well as a BringDataItemIntoView method that you could use for this. If the record has a lower index than the records that are in view, you can just call these methods, as it will scroll the grid up to the point where the desired record is in view at the top of the grid, but if it has a higher index, it will scroll until the record shows at the bottom of the grid. You can work around this by getting the number of rows that are currently in view by using the GetRecordsInView method of the XamDataGrid and scrolling the record at your record's index + X, where X is the number of rows in view.

    Another option might be to fix the SelectedItem record to the top of your grid, as this will consistently make it appear at the top. You can read about fixing records in the XamDataGrid at the following online documentation article: http://help.infragistics.com/Help/Doc/WPF/2015.1/CLR4.0/html/xamDataPresenter_Fix_Records.html.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer