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
445
XamWebGrid Row up down functionality
posted

XamWebGrid-

I have to Move up and down the XamWebGrid row on Move up and move down button.

Please suggest the way.

 

-Pankaj

Parents
  • 40030
    Offline posted

    Hi Pankaj, 

    I"m not sure what you mean?

    Are you saying that when a user hits the up and down key on the grid, you need to move the active row in the collection?

    If so, it'd look something like this:

       grid.ItemsSource = this._data;

       grid.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(grid_KeyDown), true);

            void grid_KeyDown(object sender, KeyEventArgs e)
            {

                if (grid.ActiveCell != null)
                {

                    if (e.Key == Key.Down)
                    {

                        // B/c the grid already handled the keydown and changed the active cell.

                        int index = grid.ActiveCell.Row.Index - 1;

                        Comic data = (Comic)grid.Rows[index].Data;

                        this._data.Remove(data);

                        this._data.Insert(index + 1, data);

                        // Delay so the row has time to be rendered.

                        this.Dispatcher.BeginInvoke(() =>
                         {

                                grid.ActiveCell = grid.Rows[index + 1].Cells[0];

                            });

                    }

                    else if(e.Key == Key.Up)

                    {

     

                    }

                }            

            } 

    Hope this helps, 

    -SteveZ

Reply Children
No Data