How to make the keyboard focus ring to appear on every element in Xamarin.forms?

93 views Asked by At

I have a task to make the app in my company to be keyboard accessible and while I manage to make the elements in xamarin.forms focus accessible via keyboard they are not always getting the focusRing highlight as it is supposed to. Is there some option in xamarin forms ios that can make buttons, for example always to get this focusRing highlight.

Here is a screenshot of the focusRingHighlight

1

There are 1 answers

0
Zack On

There is an IsFocused property in Xamarin, which can determine whether an element is focused. You can use this property to determine that when the button is focused, change the background color to achieve an effect similar to focusRing.

Like this:

if (myElement.IsFocused)
  myElement.BackgroundColor = Color.Red;

For more details, you can refer to the documentation :

VisualElement.IsFocused Property | Microsoft