New to Telerik UI for WPF? Download free 30-day trial

Setting focus to RadChat on load

Environment

Product Version 2019.1.220
Product RadChat for WPF

Description

How to set focus to RadChat on load.

Solution

Access the RadWatermarkTextBox inside the RadChat, using the ChildrenOfType extension method and focus it. This can be achieved in the Loaded event of the control.

<telerik:RadChat x:Name="chat" Loaded="chat_Loaded" /> 

private void chat_Loaded(object sender, RoutedEventArgs e) 
{ 
    var chat = sender as RadChat; 
    var watermarkTextBox = chat.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault(tb => tb.Name == "PART_InputBox"); 
    watermarkTextBox.Focus(); 
} 
In this article