Silverlight DataGrid maintain VerticalScrollbar position dynamically


  • Hi,

    I am using SL4 for developing client application.

    I am facing one issue with DataGrid VerticalScrollbar.

    How to maintain DG VerticalScrollbar position when data binded dynamically.

    I used DataGrid.ScrollIntoView(selectedRowIndex,dgColumn[0]); but it is not working in my case.

    Based on UI Event i rebinding the DG with ObservableColection. for binding that collection i am using following steps.





    but DG verticalScrollbar not maintaining the position.




    Monday, August 30, 2010 4:55 PM


All replies

  • Hi Sudhakar,

    I tried to get the VerticalScrollBar object from DataGrid control template. Store its position in a variable and assign it to VerticalScrollBar after DataGrid is reloaded. In this way, the vertical bar’s position can be maintained but rows in DataGrid always start from the first row (should be displayed according to scrollbar’s position).

    Basically, if you want to reorder DadaGrid according to a column, you can simply click on column header. Data will be order by that column and most importantly is that vertical scrollbar’s position will not change. But if you need to program it manually, I cannot give out a satisfied solution right now. If you get the idea, please post it here and share with me and other communities. Thanks.


    Friday, September 03, 2010 5:01 AM
  • Hi Shi Ding,

    First of all Thanks for your quick reply.

     How to get the VerticalScrollBar object from DataGrid control template. Can you please post one small example.



    Friday, September 03, 2010 7:07 AM
  • Hi  Sudhakar,

    I get VerticalScrollBar object using Expression Blend.

    For details please refer to

    I create a VerticalScrollbar_Loaded event. All what i tried is within this event.

    Sunday, September 05, 2010 9:31 PM
  • Hi,

    You might take a look at my ScrollDataGrid:

    It allows you to save the current scroll position(s), reload the grid, and reload the previous scroll position.
    This should solve your issue.

    Tuesday, September 14, 2010 5:09 AM
  • Place DataGrid inside a ScrollViewer

    Set properheight of DataGrid

    Set Scrollviewer verticalScrollbar visibility to visible

    Then in the page load event set the scrollviwer verticalofset property;

    eg: scroller.ScrollToVerticalOffset(double value)

    Compute the double value based on  ComputedVerticalScrollBarVisibility property of Scrolviewer

    Tuesday, September 14, 2010 10:45 AM
  • Hi Sandrino,

    It is very useful blog. It resolved many questions regarding Datagrid VerticalScrollbar.

    Thanks for your reply.

    Sunday, September 26, 2010 7:57 AM
  • Hi,

    I have the issue with scrolling datagrids, actually i am using three grids in my page and the are scroll synchronized, i.e. if i scroll any one of them all three are scrolled to the same record, now i placed these grids under accordion and there are three accordions(each grid in diff accordion), my problem is if i collapse one of the accordion, the grid inside does not scroll synchronously.. 

    i am writing the code of scroll on AccordionItem_Unselected event but its not working, please help its urgent. i am trying to do like this.

     GridSalaryAndCashBonus.ScrollIntoView(GridPromotion.GetScrollPosition(ScrollMode.Vertical), GridPromotion.Columns[0]);

     GridSalaryAndCashBonus.ScrollToPercent(ScrollMode.Vertical, GridEquityGrants.percent);

    Thursday, July 03, 2014 7:57 AM