New to Telerik UI for .NET MAUIStart a free 30-day trial

Using Focus and Unfocus Events in Telerik UI for .NET MAUI Chat

Updated on Apr 10, 2026

Environment

VersionProductAuthor
13.0.0Telerik UI for .NET MAUI ChatDobrinka Yordanova

Description

I want to handle the focus and unfocus events in the Telerik UI for .NET MAUI Chat control. The Chat's PromptInput uses the RadMultilineTextInput as the input element. How can I access the required events?

This knowledge base article also answers the following questions:

  • How to attach focus and unfocus events to the Chat input field in Telerik UI for .NET MAUI?
  • How to handle focus events in Chat for .NET MAUI?
  • How to subscribe to RadMultilineTextInput events in Telerik UI for .NET MAUI?

Solution

To handle the focus or unfocus event in Telerik UI for .NET MAUI Chat, access the RadMultilineTextInput inside the Chat's PromptInput on the Loaded event of the Chat control:

  1. Subscribe to the Loaded event of the Chat control.
  2. Access the visual tree descendants of the Chat to locate the RadMultilineTextInput.
  3. Attach the Focused or Unfocused event to the RadMultilineTextInput.

The following code snippet shows how to handle the focus and unfocus events:

csharp
private void Chat_Loaded(object sender, EventArgs e)
{
    // Get all visual tree descendants of the chat control.
    List<IVisualTreeElement> items = (List<IVisualTreeElement>)this.chat.GetVisualTreeDescendants();
    
    foreach (IVisualTreeElement myControl in items)
    {
        // Check if the control is RadMultilineTextInput.
        if (myControl is RadMultilineTextInput)
        {
            RadMultilineTextInput control = (RadMultilineTextInput)myControl;
            
            // Attach the Focused event.
            control.Focused += Control_Focused;
            return;
        }
    }
}

// Handle the Focused event.
private void Control_Focused(object? sender, FocusEventArgs e)
{
    // Add your logic for handling focus here.
}

Below is the XAML definition of the Chat control with the Loaded event attached:

xml
<telerik:RadChat x:Name="chat" Grid.Row="1"
                  Author="{Binding Me}"
                  Loaded="Chat_Loaded"
                  ItemsSource="{Binding Items}" 
                  ItemConverter="{StaticResource SimpleChatItemConverter}">
    <telerik:RadChat.BindingContext>
        <local:ViewModel />
    </telerik:RadChat.BindingContext>
</telerik:RadChat>

This method enables handling the focus and unfocus events for the input field in the Telerik UI for .NET MAUI Chat control.

See Also