Monday, August 30, 2010 4:55 PM
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); 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.
Friday, September 03, 2010 5:01 AM
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 7:07 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.
Sunday, September 05, 2010 9:31 PM
I get VerticalScrollBar object using Expression Blend.
For details please refer to http://forums.silverlight.net/forums/t/198690.aspx
I create a VerticalScrollbar_Loaded event. All what i tried is within this event.
Tuesday, September 14, 2010 5:09 AM
You might take a look at my ScrollDataGrid: http://sandrinodimattia.net/blog/post/Controlling-and-viewing-the-ScrollBar-positions-of-your-Silverlight-DataGrid.aspx
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 10:45 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
Sunday, September 26, 2010 7:57 AM
It is very useful blog. It resolved many questions regarding Datagrid VerticalScrollbar.
Thanks for your reply.