Focus Textbox using FocusManager.FocusedElement issue
I'm trying to set the keyboard focus to a textbox that is included in a stackpanel. When the IsEditMode becomes true i want the textbox to become, by default, focused. I've tried this code: <DataTemplate x:Key="LibraryItemTemplate"> <StackPanel Orientation="Vertical"> <StackPanel.Style> <Style TargetType="StackPanel"> <Style.Triggers> <DataTrigger Binding="{Binding IsEditMode}" Value="True"> <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=TxtB}"/> </DataTrigger> </Style.Triggers> </Style> </StackPanel.Style> <TextBlock x:Name="TxtA" Text="A" /> <TextBox x:Name="TxtB"