1
votes

I need to disable the focus in combo-box item container. In data template have textbox control. After selecting the combo-box item container open and tab key press, the cursor should flow to the text box control and second tab key press next text-box.

Actually now, first it's going to the container and second tab key it's going to text box for each combo-box items, so its takes two tab press key to reaching the textbox control in combo box item.

I need to disable the focus on combo box item container, so it reduces one tab key press.

Thanks In advance.

2

2 Answers

1
votes

use XAML code bellow could fit your requirement:

<ComboBox KeyboardNavigation.DirectionalNavigation="Cycle">
    <ComboBoxItem FocusManager.FocusedElement="{Binding ElementName=item1}">
        <ToggleButton x:Name="item1" Content="Item 1" Click="ComboBoxItem1_Clicked"/>
    </ComboBoxItem>
    <ComboBoxItem FocusManager.FocusedElement="{Binding ElementName=item2}">
        <ToggleButton x:Name="item2"  Content="Item 2" Click="ComboBoxItem1_Clicked"/>
    </ComboBoxItem>
</ComboBox>
0
votes

You could do that manually by handling the GotFocus Event in the ComboBox and set the selected item to the first one in the drop Down list

 <ComboBox x:Name="Box" GotFocus="Box_OnGotFocus" >
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="Yo"></TextBlock>
            </DataTemplate>
        </ComboBox.ItemTemplate>            
    </ComboBox>

and the here the handler

private void Box_OnGotFocus(object sender, RoutedEventArgs e)
    {
        Box.IsDropDownOpen = true;
        Box.SelectedIndex = 0;
    }