2012-10-23 5 views
1

ListBox에서 사용자 정의 컨트롤을 사용하고 탭 키를 사용하여 포커스를 지정하면 사용자 정의 컨트롤 대신 컨트롤의 TextBox에 포커스를 맞추고 싶습니다. 내가 어떻게 해?ListBox에서 사용자 정의 탭 컨트롤 DataTemplate

제 컨트롤에는 다른 UI 요소가 있기 때문에 코드가 단순 해졌습니다.

사용자 컨트롤 코드 :

<Grid> 
    <TextBox Name="txtFreeTextDescription" Style="{StaticResource TextBoxStyleLargeDynamic}" Text="{Binding Description, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" /> 
</Grid> 

목록 상자 코드 : 링크 아래

<ListBox Name="lsbItems" DataContext="{Binding}" KeyboardNavigation.TabNavigation="Local"> 
     <ListBox.ItemTemplate> 
     <DataTemplate> 
      <local:SectionDynamicItem x:Name="ucSectionDynamicItem" Description="{Binding SectionItem.Description}" /> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
</ListBox> 

답변

2

이 나를 위해 작동합니다 ....

<ListBox ItemsSource="{Binding EmployeeList}" 
      KeyboardNavigation.TabNavigation="Continue"> 
     <ItemsControl.ItemContainerStyle> 
      <Style TargetType="ListBoxItem"> 
       <Setter Property="Focusable" Value="False"/> 
      </Style> 
     </ItemsControl.ItemContainerStyle> 
     <ItemsControl.ItemsPanel> 
      <ItemsPanelTemplate> 
       <StackPanel Orientation="Horizontal"/> 
      </ItemsPanelTemplate> 
     </ItemsControl.ItemsPanel> 
     <ItemsControl.ItemTemplate> 
      <DataTemplate> 
       <Grid Margin="5" Focusable="False"> 
        <TextBox Text="{Binding Name}"/> 
       </Grid> 
      </DataTemplate> 
     </ItemsControl.ItemTemplate> 
    </ListBox> 
+2

감사합니다 한 트릭 잘에게 ! –

관련 문제