Home Forums WPF controls Xceed DataGrid for WPF scroll to selected (or current) Item

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23999 |

    Hello!
    I would like to know, how can I NavigateTo the selected Item in a DataGridControl, if my SelectedItem is out the visible area of datagrid…

    Imported from legacy forums. Posted by serhio (had 710 views)

    User (Old forums)
    Member
    Post count: 23064

    Take a look at DataGridControl.BringItemIntoView

    http://doc.xceedsoft.com/products/XceedWpfDataGrid/Xceed.Wpf.DataGrid~Xceed.Wpf.DataGrid.DataGridControl~BringItemIntoView.html

    Imported from legacy forums. Posted by Richard (had 408 views)

    User (Old forums)
    Member
    Post count: 23064

    this does not work 🙁

    dgListeArticles.SelectedIndex = i;
    dgListeArticles.CurrentItem = dgListeArticles.SelectedItem;
    dgListeArticles.BringItemIntoView(dgListeArticles.CurrentItem);
    dgListeArticles.UpdateLayout();

    (with, or without last line, anyway)

    Imported from legacy forums. Posted by serhio (had 759 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried to extract the dataRow from the control, but this does not work too:
    Xceed.Wpf.DataGrid.DataRow dr = (Xceed.Wpf.DataGrid.DataRow)dgListeArticles.ItemContainerGenerator.ContainerFromIndex(dgListeArticles.SelectedIndex);
    dr.BringIntoView();

    obtained “dr” is null…

    Is this a correct approach to obtain the current row from the dataGridControl?

    Imported from legacy forums. Posted by serhio (had 342 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    I do remember trying a few different things when investigating this.

    I’m using the following code to get the DataRow instead of the call you’re using:

    DataRow row = XceedDataGrid.GetContainerFromItem(XceedDataGrid.CurrentItem) as DataRow;

    I vaguely remember trying something from the docs that had been deprecated, it could be the call you’re using.

    ** Make sure you have the most recent Xceed WPF DataGrid.

    If you’re unable to get the current DataRow it seems there is something basically wrong

    Rich

    Imported from legacy forums. Posted by Richard (had 440 views)

    User (Old forums)
    Member
    Post count: 23064

    Check this out:

    http://doc.xceedsoft.com/products/XceedWpfDataGrid/Changes%20since%20version%201.0.html

    The DataGridControl.ItemContainerGenerator property has been obsoleted, and the relevant methods have been added to the DataGridControl class (GetContainerFromIndex, GetContainerFromItem, GetIndexFromContainer, and GetItemFromContainer).

    Imported from legacy forums. Posted by Richard (had 316 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m hoping that there will be a whole bunch of RoutedUICommands available in v1.2 to make this sort of thing easier. That would sure beat the alternative of every developer using the Xceed WPF DataGridControl creating their own logic to excute the equivalent of a RoutedUICommand named something like GotoCurrentItemCommand.

    If you agree let the Xceed team know about the suggestion… maybe they’ll slip it into a new version for us 🙂

    Imported from legacy forums. Posted by Richard (had 594 views)

    User (Old forums)
    Member
    Post count: 23064

    ja… I have the version 1.0 of DataGridControl…

    In the latest 1.1 version is “added the DataGridControl.ItemScrollingBehavior property, which allows configuring how item scrolling behaves in the grid (immediate or deferred scrolling). “

    I will try to update and use it, hope this helps…

    Imported from legacy forums. Posted by serhio (had 6015 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.