The Application
I am building an application which includes a range selector. This consists of two custom drawn Slider
controls contain
By default when a control receives the logical focus, FrameworkElement calls its own BringIntoView method (from within its OnGotFocus method if it has keyboard focus). That results in a RequestBringIntoView event being generated that bubbles up the element tree to allow ancestor elements to bring that portion of the element into view. The ScrollViewer listens for this event and eventually will call MakeVisible on the associated IScrollInfo/ScrollContentPresenter which leaves it up to the panel to bring that portion into view (since the panel would know how it arranges its children). It then takes that returned rect it receives back and asks for that portion of itself to be brought into view (in case you had nested elements that would require some action to ensure the original element was brought into view). So one way to suppress this behavior would be to handle the RequestBringIntoView event on the sliders and mark the event handled.
This may not work in this specific scenario, but a simple, clean solution to prevent a ScrollViewer
from scrolling a focused element into view is to make the element unfocusable via Focusable=False
. If an element cannot be focused then it will also not be automatically scrolled into view.