1

I want to vertically scroll a WPF UI-element (a datagrid) by using Microsofts UIAutomation.

inspect.exe shows me that the property VerticallyScrollable is true and HorizontallyScrollable is false, which is correct:

enter image description here

Further, if I use the Scroll-feature of inspect.exe, I am able to correctly scroll the datagrid (e.g. by a "Small Increment":

enter image description here

Now, I want to use this logic in my C# code, which doesn't work.

This is what I am doing:

// dataGrid correctly contains my UI-element.
ScrollPattern pattern = dataGrid.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;

// neither this works, ...
pattern.ScrollVertical(ScrollAmount.SmallIncrement);

// ... nor this works.
pattern.Scroll(ScrollAmount.NoAmount, ScrollAmount.SmallIncrement);

Further, if I look at the VerticallyScrollable property of the ScrollPattern, it is set to false - which does not correspond to the reality, since the element is scrollable (by hand, as well as automated by inspect.exe):

enter image description here

What I am getting is this exception, after I called e.g. pattern.ScrollVertical(ScrollAmount.SmallIncrement);:

enter image description here

Why is it working from out of inspect.exe but not by code?

marc wellman
  • 5,808
  • 5
  • 32
  • 59

0 Answers0