views:

78

answers:

2

Guys,

What's up :-) Need your help.

My control is constructed from nested list boxes and tree views. Each list box / tree view item also contains rich text boxes and other controls.

I want to define a 'tab' focus behavior such that when the user clicks 'Tab' the next focusable item (according to an order i define) will become focused.

Currently it doesn't work as i accept (it only works partially).

My question is not specific to my case - rather on how to define such behavior at all. As an extreme example, let's say i want to completely control this and make the focus jump between items not physically near.

Anyone might know how this can be controlled?

YOUR HELP WILL BE APPRECIATED :-) Gili

A: 

Are you looking for the KeyboardNavigation.TabIndex property?

Joe White
Hi Joe, thanx for your quick replay. This might be possible solution. The thing is that my document is extremely complex, user can move items up and down - will i have to manage this indexes. Do you know how this would behave on nested list boxes? For example the outer items will be indexed from 0-N and inner items will also be index from 0-M, if this is the case - your suggestion will work for me.
Gilad
I've never nested one listbox inside another, so I'm not sure. If you're trying to use Tab to move between list items in the same list box, you might need to play with KeyboardNavigation.TabNavigation on the ListBox. It looks like the default tab order goes between controls in the same list item, then to the next list item. If you need something different, take a look at the other properties on KeyboardNavigation. If you're still stuck, I think you'll have to post a more specific question.
Joe White
A: 

Joe, this mechanism is smarter than i thought, check this nesting - it works perfectly:

        <ListBox KeyboardNavigation.TabNavigation="Continue">
            <ListBoxItem Focusable="False">
                <ListBox KeyboardNavigation.TabNavigation="Continue">
                    <ListBox.Items>
                        <ListBoxItem Focusable="False">
                            <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                        </ListBoxItem>
                        <ListBoxItem Focusable="False">
                            <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                        </ListBoxItem>
                        <ListBoxItem Focusable="False">
                            <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                        </ListBoxItem>
                    </ListBox.Items>
                </ListBox>
            </ListBoxItem>
            <ListBoxItem Focusable="False">
                <ListBox KeyboardNavigation.TabNavigation="Continue">
                    <ListBox.Items>
                        <ListBoxItem Focusable="False">
                            <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                        </ListBoxItem>
                        <ListBoxItem Focusable="False">
                            <StackPanel>
                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                <Border BorderBrush="Red">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBoxItem Focusable="False">
                                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                                <ListBox.Items>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                                    </ListBoxItem>
                                                </ListBox.Items>
                                            </ListBox>
                                        </ListBoxItem>
                                        <ListBoxItem Focusable="False">
                                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                                <ListBox.Items>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                                    </ListBoxItem>
                                                </ListBox.Items>
                                            </ListBox>
                                        </ListBoxItem>
                                    </ListBox>
                                </Border>
                            </StackPanel>
                        </ListBoxItem>
                        <ListBoxItem Focusable="False">
                            <StackPanel>
                                <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                <Border BorderBrush="Red">
                                    <ListBox KeyboardNavigation.TabNavigation="Continue">
                                        <ListBoxItem Focusable="False">
                                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                                <ListBox.Items>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                                    </ListBoxItem>
                                                </ListBox.Items>
                                            </ListBox>
                                        </ListBoxItem>
                                        <ListBoxItem Focusable="False">
                                            <ListBox KeyboardNavigation.TabNavigation="Continue">
                                                <ListBox.Items>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="1" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="2" Focusable="True"/>
                                                    </ListBoxItem>
                                                    <ListBoxItem Focusable="False">
                                                        <TextBox Width="300" KeyboardNavigation.TabIndex="3" Focusable="True"/>
                                                    </ListBoxItem>
                                                </ListBox.Items>
                                            </ListBox>
                                        </ListBoxItem>
                                    </ListBox>
                                </Border>
                            </StackPanel>
                        </ListBoxItem>
                    </ListBox.Items>
                </ListBox>
            </ListBoxItem>
        </ListBox>


    </StackPanel>

</Grid>

:-) Thanx a lot for the Help!

Gilad