I have a ListBox with horizontal orientation inside a ScrollViewer. When the list grows, it automatically scrolls to the last element. The scrollbars work, however must be disabled for this. I need to have separate buttons which would scroll the ScrollViewer by a predetermined iteration (much like buttons on the scrollbars). For this, I have tried:
sv.ScrollToHorizontalOffset(sv.HorizontalOffset + 20);
However, the ScrollViewer's HorizontalOffset seems to always be 0, and the method doesn't do anything with any values.
sv.LineRight();
sv.LineLeft();
both don't work, probably because the only child element is the ListBox. If I change the ListBox's orientation to vertical, then the ScrollViewer's VerticalOffset changes with scrolling/adding new elements, and ScrollToVerticalOffset works correctly. Why is this different with horizontal orientation? Any other solutions?
Note: this was done without using XAML to place the controls.