This is a migrated thread and some comments may be shown as answers.
How to scroll content in ScrollViewer WPF element
7 Answers 62 Views
This is a migrated thread and some comments may be shown as answers.
Stanislav
Top achievements
Rank 1
Stanislav asked on 09 Apr 2013, 06:28 AM
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

7 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 12 Apr 2013, 11:14 AM
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
0
Stanislav
Top achievements
Rank 1
answered on 16 Apr 2013, 02:40 AM
Hello Plamen,

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

Kind Regards,
Stanislav Hordiyenko
0
Plamen
Telerik team
answered on 16 Apr 2013, 07:27 AM
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
0
Palvi
Top achievements
Rank 1
answered on 07 Jul 2020, 01:57 PM

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,

0
Elena
Telerik team
answered on 08 Jul 2020, 01:23 PM

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.
0
Palvi
Top achievements
Rank 1
answered on 08 Jul 2020, 01:37 PM

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);

 

0
Elena
Telerik team
answered on 13 Jul 2020, 11:24 AM

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

Asked by
Stanislav
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Stanislav
Top achievements
Rank 1
Palvi
Top achievements
Rank 1
Elena
Telerik team
Share this question
or