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:
Further, if I use the Scroll-feature of inspect.exe, I am able to correctly scroll the datagrid (e.g. by a "Small Increment":
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):
What I am getting is this exception, after I called e.g. pattern.ScrollVertical(ScrollAmount.SmallIncrement);
:
Why is it working from out of inspect.exe but not by code?