This is a migrated thread and some comments may be shown as answers.

Setting Grid Scroll Position

4 Answers 971 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Andrews
Top achievements
Rank 1
Chris Andrews asked on 05 Oct 2010, 10:14 PM
Hello, let's start with a little background on our app.

We use RadDocking with a RadGridView in one of the panes.  The problem we have is the scroll position is getting reset to the top row when the pane containing the grid is pinned or unpinned (It seems to re-get the bound ItemsSource each time the grid is loaded and unloaded causing the grid to refresh).  To try getting around this issue I tried getting and setting the scrollbar's value when the grid is loaded / unloaded.  However, when I set the scrollbar's value, I am unable to physically move the scrollbar.  I can however see the items changing as if it was scrolling properly, just the bar doesn't move.  I am using the latest 9/24/2010 release.

I added a simple WPF ScrollBar control and I can set the value and still scroll the control properly.

Is this an issue with the ScrollBar the grid is using?

If there is any other recommendations on how to keep the scroll position, I am open to that as well.

Here is some quick code showing how I am doing this.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
    // Get GridView ScrollBar object
    ScrollBar verticalScrollBar = this.RadGridView1.ChildrenOfType<ScrollBar>().Where(s => s.Orientation == Orientation.Vertical).First();
  
    // Set value on GridView - Goes to bottom, but cannot get scrollbar to move
    verticalScrollBar.Value = verticalScrollBar.Maximum;
  
    // Set value on WPF ScrollBar - Goes to bottom, and scrollbar moves fine
    this.WpfBar1.Value = this.WpfBar1.Maximum;
}


Thanks All for your help.

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 08 Oct 2010, 03:17 PM
Hello Chris Andrews,

I have managed to reproduce the initial problem - pin/unpin resets the ItemsSource (even if the standard ListBox is in RadPane). This happens only in the WPF version of the RadDocking and we have logged it for fixing.
I have updated your Telerik points.

As a workaround you can set the DataContext property of RadPane to your ViewModel:

<Window.Resources>
       <my:MyViewModel x:Key="MyViewModel"/>
   </Window.Resources>
   <Grid x:Name="layout">
       <telerik:RadDocking Height="150" Width="400" PreviewPin="RadDocking_PreviewPin" PreviewUnpin="RadDocking_PreviewUnpin" PaneStateChange="RadDocking_PaneStateChange">
           <telerik:RadSplitContainer>
               <telerik:RadPaneGroup>
                   <telerik:RadPane Header="GridView" DataContext="{StaticResource MyViewModel}" >
                       <ListBox ItemsSource="{Binding Clubs}" DisplayMemberPath="Name"></ListBox>
                   </telerik:RadPane>
               </telerik:RadPaneGroup>
           </telerik:RadSplitContainer>
       </telerik:RadDocking>
   </Grid>

Hope this helps.

Greetings,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris Andrews
Top achievements
Rank 1
answered on 08 Oct 2010, 07:59 PM
Thank You.  I will give this workaround a try.

Can you confirm my findings on the scrollbar not moving in the grid when you set the value?  I think this may be another issue.
0
Chris Andrews
Top achievements
Rank 1
answered on 09 Oct 2010, 06:49 PM
On a further note about the scroll bar, this happens in WPF without the Rad Docking.  The issue does not exist in silverlight, but another thing I noticed is even though you set the value of the scroll bar, the row's do not scroll until you click the scroll bar slider.

I can provide a test project if needed.
0
Veselin Vasilev
Telerik team
answered on 13 Oct 2010, 04:17 PM
Hello Chris Andrews,

A working example using the latest assemblies would be great.

Thank you.

Sincerely yours,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Chris Andrews
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Chris Andrews
Top achievements
Rank 1
Share this question
or