VisualElement.IsFocused VisualElement.IsFocused Property


Gets a value indicating whether this element is focused currently. This is a bindable property.

public bool IsFocused { get; }
member this.IsFocused : bool
Property Value

true if the element is focused; otherwise, false.


Applications may have multiple focuses depending on the implementation of the underlying toolkit. Menus and modals in particular may leave multiple items with focus.

The following example shows conditionally setting a background color based on the focus state.

  void UpdateBackground ()
    if (myElement.IsFocused)
      myElement.BackgroundColor = Color.Red;
      myElement.BackgroundColor = Color.Blue;

Applies to