Home Forums WPF controls Xceed DataGrid for WPF Need help with PageUp/PageDown in custom Navigator Control

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #23920 |

    Hi I’m writing a navigator control that will be part of my grid footer. It will have the commands listed below, at the end of this message.

    I have 3 questions I need help with, ** Many Thanks In Advance **, Rich

    (1) How can I determine the first and last visible row in the view port after a ScrollViewer change ? In other words, how do I determine the underlying item for the first virtualized row currently displayed on screen?

    I would like my navigator PageUp/PageDown/First/Last commands to mimc the way the grid works but I can’t find any existing command bindings to re-use, so I created my own.

    The default grid PageUp/PageDown/Ctrl-PageUp/Ctrl-PageDown behavior pages to the requested location and moves the CurrentItem be the first or last row in the ScrollViewer Viewport.

    How could I mimic this behavior?

    Using the method below I’m able to call ScrollViewer.PageDown() for example to page down, but I don’t know which rows are currently displayed in the Viewport and therefore do not know which row to make the new CurrentItem.

    For my PageUp/PageDown commands I’m using the ScrollViewer as shown:

    ScrollViewer sv = dataGrid.Template.FindName(“PART_ScrollViewer”, navi.XceedDataGrid) as ScrollViewer;

    if (sv != null)

    (2) What Command or method should be called to mimic the “ESC” key feature? Using Cell.CancelEdit appears to commit the current edit in progress.

    For my CancelEdit command I call CancelEdit on the current cell as follows:

    Cell currentCell = …

    (3) Will v1.2 include a navigator control or additonal grid commands to make it easiser to write one?


    static public RoutedUICommand PreviousItem;
    static public RoutedUICommand NextItem;
    static public RoutedUICommand FirstItem;
    static public RoutedUICommand LastItem;
    static public RoutedUICommand PageDown;
    static public RoutedUICommand PageUp;
    static public RoutedUICommand CancelEdit;
    static public RoutedUICommand BeginEdit;
    static public RoutedUICommand EndEdit;
    static public RoutedUICommand DeleteItem;
    static public RoutedUICommand RestoreItem;

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

    Xceed Support
    Post count: 5658

    1) The first visible row can be determined by accessing the ScrollViewer’s “VerticalOffset” (if the panel has Vertical orientation).

    From that offset, you can call myDataGridControl.GetContainerFromIndex( first ) to obtain the UI Element for the row (Note: it is possible that the element returned is not for a Data item. e.g. GroupHeaderControl ).

    Same goes for the last visible, but instead of VerticalOffset, you can use: VerticalOffset + ViewportHeight – 1

    2) The problem here is not that the Cell.CancelEdit commits the edition, its mainly because as soon as you click elsewhere, the current row in edition gets commited…

    There is currently no workaround to avoid this “limitation”…

    3) No Navigator is to be included in v1.2, some additional command (not a ton however) but none of those listed in your post…

    Imported from legacy forums. Posted by Marcus [Xceed] (had 2635 views)

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