Wpf 如何在同一TreeViewItem中的ComboBox SelectionChanged事件中设置文本框的焦点

Wpf 如何在同一TreeViewItem中的ComboBox SelectionChanged事件中设置文本框的焦点,wpf,focus,treeviewitem,Wpf,Focus,Treeviewitem,因此树视图项的数据模板: <DataTemplate> <StackPanel Orientation="Horizontal"> <ComboBox Name="CB" /> <TextBox Name="TB" /> </StackPanel> <DataTemplate> 当我更改组合框选择时,如何将焦点放在文本框上?如果您将FocusManager.Focused

因此
树视图项的
数据模板

<DataTemplate>
    <StackPanel Orientation="Horizontal">
        <ComboBox Name="CB" />
        <TextBox Name="TB" />
    </StackPanel>
<DataTemplate>


当我更改
组合框
选择时,如何将焦点放在
文本框
上?

如果您将
FocusManager.FocusedElement=“{Binding ElementName=TB}”
放在
组合框
上,单击
组合框
打开和关闭后(即使您没有选择任何内容),它会将焦点发送到
文本框
,虽然我相信有更好的方法,但最终对我来说效果很好