How to scroll content in ScrollViewer WPF element

7 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 2 days and 14 hours ago 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
    1215 posts

    Posted 1 day and 14 hours ago 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 1 day and 14 hours ago 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);

     

Back to Top