How to scroll content in ScrollViewer WPF element

8 posts, 1 answers
  1. Stanislav
    Stanislav avatar
    1 posts
    Member since:
    May 2012

    Posted 09 Apr 2013 Link to this post

    Hello Telerik,

    There is ScrollViewer WPF element in the application. I was able to identify it, but I couldn't find any methods how I can scroll the content inside the element. How can I do so?

    Thank you.

    Kind Regards,
    Stanislav Hordiyenko
  2. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 12 Apr 2013 Link to this post

    Hi Stanislav,

    I apologize for the delay in getting back to you on this. Please take a look at this Silverlight code sample article. You can easily adapt it to suit your needs. Here's an example against one of our WPF demos:
    public GridViewCell FindGridViewCellByText(string cellToFind, RadGridView grid)
    {            
        ScrollViewer scrViewer = grid.Find.ByType("GridViewScrollViewer").CastAs<ScrollViewer>();
        double scrollPos = 0;
     
        do
        {                               
            for (int i = 0; i < grid.Rows.Count; i++)
            {
                if (grid.Rows[i].Cells[0].TextBlockContent.Contains(cellToFind))
                {                                               
                    return grid.Rows[i].Cells[0];
                }
            }
            
            scrollPos += scrViewer.ViewportHeight;
            scrViewer.InvokeMethod("ScrollToVerticalOffset", scrollPos);
            grid.Refresh(); // Refresh our cached copy of the grid.
     
        }
        while (scrollPos <= scrViewer.ExtentHeight);
        return null;
    }

    Then you can call that method like this:
    RadGridView grid = ActiveApplication.MainWindow.Find.ByName<RadGridView>("RadGridView1");
    Assert.IsNotNull(grid);
     
    FindGridViewCellByText("Cell 415 0", grid).User.Click();

    See this video demonstrating the execution.

    Hope this helps!

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Stanislav
    Stanislav avatar
    1 posts
    Member since:
    May 2012

    Posted 15 Apr 2013 Link to this post

    Hello Plamen,

    Thank you for your reply. It is working. I have marked your message as an answer.

    Kind Regards,
    Stanislav Hordiyenko
  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 16 Apr 2013 Link to this post

    Hello Stanislav,

    Glad to hear it! Please contact us again if you have further problems.

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Palvi
    Palvi avatar
    3 posts
    Member since:
    Apr 2020

    Posted 07 Jul Link to this post

    Hello Telerik,

    I am trying to perform Scrolling in RadGanttView. But not able to find any help on how to scroll in it. I have tried with above code and also with solution mentioned here but no success. Can you please suggest any other solution.

    https://docs.telerik.com/devtools/teststudiodev/code-in-test/coded-samples/silverlight/radgridview-automation/scrolling.html

    Thanks,

  6. Elena
    Admin
    Elena avatar
    1221 posts

    Posted 08 Jul Link to this post

    Hi Palvi,

    As far as I understand you are using the Test Studio Testing Framework to automate a RadGanttView control. You can find that Class properties and methods listed here, which can help you in identifying how to automate the control. 

    As a side note to this topic, I tested a sample application with that control and noticed there are both vertical and horizontal scrollers, which appear on hovering the mouse over them. Going through the app DOM tree I noticed there are buttons to control the scrolling on these. I managed to automate the scrolling using these buttons and sending a UserPress actions against them. 

    I hope these notes will be beneficial for you to continue your automation project.

    Thank you for your cooperation in advance.

    Regards,
    Elena
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  7. Palvi
    Palvi avatar
    3 posts
    Member since:
    Apr 2020

    Posted 08 Jul in reply to Elena Link to this post

    Hello Elena,

    Thank you for your response. I am using Telerik Testing framework(Free tool). I also tried the ScrollToVisible() method as well. In the Gantt there is GridVirtualizingPanel with vertical scrollBar. I have tried the below code but getting an exception no method with name "SetVerticalOffset".

    FrameworkElement VirtualizingPanel = gantt.Find.ByType("GridVirtualizingPanel");

    VirtualizingPanel.InvokeMethod("SetVerticalOffset", 0);

     

  8. Elena
    Admin
    Elena avatar
    1221 posts

    Posted 13 Jul Link to this post

    Hi Palvi,

    I am not familiar in details of the specific implementation of the Gantt control in the tested application. Though, I used the sample Telerik WPF demo application for testing purposes. 

    The sample implementation of the discussed control does not support the direct scrolling through a method in the Testing framework. For this I submitted a feature request to our public feedback portal - you can find the item here

    So, the approach you can go for, is to use the visual scrollers on the GanttView control, which I mentioned before - please, see the screenshot attached. The buttons you can use to scroll the content are listed in the app visual tree as separate buttons with unique names. I used the Test Studio tool to automate these and it worked with the UserPress() method invoked on the RepeatButton control. 

    You can explore the custom application under test and what options there are to automate the scrolling in it. In case you need further assistance, I will appreciate if you can prepare a sample app to demonstrate how the control is used on your end. Since it is quite complex control, it will be nice to know as much details as possible. 

    Thank you once again for your time and cooperation.


    Regards,
    Elena
    Progress Telerik

Back to Top