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

Scrolling

5 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
hamish
Top achievements
Rank 1
hamish asked on 15 Aug 2014, 04:54 PM
I am using a radpivotgrid which is inside a radpane which is inside a radsplitcontainer. I tehn have the field list in a separate container to the right so I can resize, move and float the field list.

One of these controls (I suspect the split container) automatically shows vertical and horizontal scroll bars when necessary and what I want to do is grab these scoll positions when the users scrolls, save them and then next time restore them so the content is scrolled as they last saw it.

I cannot seem to find any events or properties that would do this for me in any of these controls. Can you tell me whether this is possible and if so how I go about it

Thanks

5 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 18 Aug 2014, 11:51 AM
Hi Hamish,

The ScrollBars you mentioned are coming from the PivotGrid Template. So what I can suggest you would be manually get them from the Template of the PivotGrid and subscribe to their ValueChanged event - you can do all that in the Loaded event handler of the PivotGrid as shown below:

private void pivot_Loaded(object sender, RoutedEventArgs e)
{
    var verScrollBar = this.pivot.Template.FindName("PART_VerticalScrollBar", this.pivot) as ScrollBar;
 
    if (verScrollBar != null)
    {
        verScrollBar.ValueChanged += verScroll_ValueChanged;
    }
}
 
void verScroll_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{  
    // save the value here e.NewValue
}

This way you will be able to save their value each time the scroller moves. The other ScrollBar is named PART_HorizontalScrollBar.

Hope this will work for you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
hamish
Top achievements
Rank 1
answered on 19 Aug 2014, 03:39 PM
Thank you for your reply however I still have a couple of questions.
1. In the line of code below Visual studio is telling me that 'ScrollBar' is invalid - can you tell me what name space this is in?
2. This event is fired when I initial load the pivot table at which point no scroll bars are visible. Then I load data into the pivot grid but the event does not fire again. My question is will rge variable verScrollBar be null if NO data is in the pivot table.

Thanks

var verScrollBar = this.pivot.Template.FindName("PART_VerticalScrollBar", this.pivot) as ScrollBar;
0
Kalin
Telerik team
answered on 20 Aug 2014, 12:30 PM
Hi Hamish,

I'll go straight to your questions:

1. The ScrollBar is located in the System.Windows.Controls.Primitives namespace.

2. Can share some more details on how/when do you load the data? The ScrollBars are present in the PivotGrid Template, so they won't be null if there is no data loaded in the PivotGrid, their value would be 0, though.

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
hamish
Top achievements
Rank 1
answered on 28 Aug 2014, 05:20 PM
I did what you suggested and I can save the current scroll bar position and then restore it by setting the value of the instance of the scollbar. This correctly positions the scrollbar where I expect it, however the underlying pivotgrid does not scroll. So what happens is that the scrollbar is all the way to the right but the data is all the way to the left.
Is there something I need do to get the Pivot to scroll at the same time I set the scrollbar value?
Thanks
0
Rosen Vladimirov
Telerik team
answered on 01 Sep 2014, 07:32 AM
Hello Hamish,

It looks like there is some problem with scrolling when you set the value directly. However I suggest you to call Scroll event of the ScrollBar and this way RadPivotGrid will be scrolled correctly:
var vertScrollBar = this.radPivotGrid.Template.FindName("PART_VerticalScrollBar", this.radPivotGrid) as ScrollBar;
 
if (vertScrollBar != null)
{
       var args = new ScrollEventArgs(ScrollEventType.LargeDecrement, 200);
       vertScrollBar.RaiseEvent(args);
}

Instead of the value 200, you can put your own value.

Hope this helps. Feel free to contact us in case you have any problems or concerns.

Regards,
Rosen Vladimirov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
General Discussions
Asked by
hamish
Top achievements
Rank 1
Answers by
Kalin
Telerik team
hamish
Top achievements
Rank 1
Rosen Vladimirov
Telerik team
Share this question
or