Scrolling

6 posts, 0 answers
  1. hamish
    hamish avatar
    44 posts
    Member since:
    Jun 2007

    Posted 15 Aug 2014 Link to this post

    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
  2. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 18 Aug 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. hamish
    hamish avatar
    44 posts
    Member since:
    Jun 2007

    Posted 19 Aug 2014 in reply to Kalin Link to this post

    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;
  5. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 20 Aug 2014 Link to this post

    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.
     
  6. hamish
    hamish avatar
    44 posts
    Member since:
    Jun 2007

    Posted 28 Aug 2014 in reply to Kalin Link to this post

    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
  7. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 01 Sep 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready