I have the following XAML:
Please try this code snipped below to get the TextBox in ListBoxItem.
ListBox listbox = element as ListBox;
if (listbox != null && listbox.SelectedItem !=null)
{
//find textbox and set focus here
Textbox thisTextBox = (listbox.SelectedItem).Find("txt1") as Textbox;
if(thisTextBox !=null)
{
thisTextBox.Focus();
return;
}
}
int children = VisualTreeHelper.GetChildrenCount(element);
for (int i = 0; i < children; i++)
{
DependencyObject child = VisualTreeHelper.GetChild(element, i);
SetFocusOnTextBox(child);
}