First input control in the Scroll viewer is always getting focused. RRS feed

  • Question

  • Hi All,

    I'm facing a weird behavior of ScrollViewer while using input controls in ScrollViewer. Say I've a couple of TextBoxes in a Scrollviewer, I'm setting the focus to the second TextBox by tapping on it, now if i tap somewhere else with in the ScrollViewer, the second TextBox lose its focus as expected. But the first TextBox is getting focused now. It happens even for all type of input controls like ComboBox etc. Not sure whether it is the expected behavior or something else needed to avoid this. Is it a bug or is it a default behavior of ScrollViewer? Is there a way to avoid this ? 

    I've uploaded a Sample in SkyDrive, Its simple to reproduce in the sample. Just tap on the second TextBox and then tap somewhere on the ScrollViewer(Gray area), first TextBox will be focused.

    - Ram 

    • Edited by Ramprasath R Monday, August 5, 2013 10:56 AM typo
    Monday, August 5, 2013 10:49 AM


  • The ScrollViewer control by default does not take focus, it sets focus to its first focusable child. Hence, when you tap outside your input control and inside the Scrollviewer, the first textbox is given focus by the ScrollViewer. To work around this, you can the IsTabStop property on ScrollViewer to TRUE - this way the ScrollViewer will set focus to itself and not to its first focusable child.

    Harini Kannan | Program Manager, XAML

    • Marked as answer by Ramprasath R Monday, August 5, 2013 5:51 PM
    Monday, August 5, 2013 4:49 PM