How to make ScrollView IsTabStop true only if the scroll bar is present?

On UWP, I have a ScrollView that has IsTabStop=true and that has TabIndex set to an appropriate value. Using ScrollView, the scroll bar is only visible (or space is only allocated for the scroll bar) if the children of the ScrollView do not fit in the space available. The user can only do something with the ScrollView (such as using the cursor keys to scroll) if the children of the ScrollView do not fit in the space available. It would appear then that nothing useful is achieved by being able to tab onto the ScrollView unless the children of the ScrollView do not fit in the space available. Is there any way, without using a custom renderer, to have IsTabStop=false when the children fit and have IsTabStop=true when the children do not fit (or have the ScrollView behave as if that is the case).

Best Answer

  • JohnHardmanJohnHardman GB mod
    edited April 13 Accepted Answer

    To identify whether the scroll bar is currently visible on UWP, I ended up subclassing Xamarin.Forms.ScrollView and adding a custom ScrollView renderer to operate on that subclass.

    The native control on UWP for the ScrollView is the ScrollViewer.
    This has ComputedVerticalScrollBarVisibility and ComputedHorizontalScrollBarVisibility, which I compare with Visibility.Visible.
    I then set boolean properties in the ScrollView subclass to indicate whether the scroll bars are visible or not.
    In the subclass, I do various things, one of which is to change IsTabStop. That could be done in the custom renderer, but as there are other things I do in the subclass when the scroll bars appear or disappear, it seemed to make sense to change IsTabStop there.

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    It is platform related, why don't you want to use custom renderer to achieve that? There's even no Tab key on iOS and Android.

  • JohnHardmanJohnHardman GBUniversity mod
    edited November 2018

    @LandLu said:
    It is platform related, why don't you want to use custom renderer to achieve that?

    I just happen to be addressing it on UWP first, before testing on Android and iOS. I can do it with custom renderers, but IMHO it should be something that the XF ScrollView does for us. I was hoping that there was a XF property that I didn't know about to make this happen.

    @LandLu said:
    There's even no Tab key on iOS and Android.

    That's not correct. I use a physical bluetooth keyboard when checking accessibility using Android and iOS devices, as well as having Android devices that have their own physical keyboard (see image of an Asus Android device with it's own keyboard, and the bluetooth keyboard that I use across platforms). Those keyboards do have a Tab key. Anybody concerned with accessibility should support physical keyboards and assistance software that requires keyboard-like behavior. The last time I checked, the legislation in some countries requires some software used by the general public to be accessible (e.g. in lay terms, if you are a business offering a service, you cannot implement it in such a way that means it's inaccessible to some potential users, as that discriminates against those users - some users can utilise the service, some cannot).

  • JohnHardmanJohnHardman GBUniversity mod
    edited April 13 Accepted Answer

    To identify whether the scroll bar is currently visible on UWP, I ended up subclassing Xamarin.Forms.ScrollView and adding a custom ScrollView renderer to operate on that subclass.

    The native control on UWP for the ScrollView is the ScrollViewer.
    This has ComputedVerticalScrollBarVisibility and ComputedHorizontalScrollBarVisibility, which I compare with Visibility.Visible.
    I then set boolean properties in the ScrollView subclass to indicate whether the scroll bars are visible or not.
    In the subclass, I do various things, one of which is to change IsTabStop. That could be done in the custom renderer, but as there are other things I do in the subclass when the scroll bars appear or disappear, it seemed to make sense to change IsTabStop there.

Sign In or Register to comment.