How to focus a datatemplated TextBox in the first element of an ItemsControl in a Window, when the Window is opened? (C#, WPF)
问题 When the user clicks a button in the application, a window opens up. I want the TextBox belonging to the first item in the ItemsControl to be focused, so that the user can start typing as soon as the Window is opened, without needing to manually select the TextBox. How can this be done? For simplicity, we can say that the Window looks approximately like this: <Window> <Grid> <ItemsControl ItemsSource="{Binding MyItems}"> <DataTemplate> <Grid> <StackPanel> <StackPanel> <customControls