Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Tabbing in Silverlight (is this a bug)
7 replies. Latest Post by Nikotromus on June 30, 2009.
(0)
Nikotromus
Member
1 points
25 Posts
06-29-2009 4:53 PM |
I a stuck on an issue. The xaml below tabs through just fine in WPF. In Silverlight, It does not want to jump outside of the grid container. It should tab in the order of 0, 1, 2, 3. If you copy this code in silerlight, you will see what I mean. Any insight on this will be very much appreciated. Thanks, Ryan <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> <Grid Grid.Row="0" Width="100" Height="50"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <TextBox Grid.Row="0" TabIndex="0" Width="50" Text="0"/> <TextBox Grid.Row="1" TabIndex="2" Width="50" Text="2"/> </Grid> <Grid Grid.Row="1" Width="100" Height="50"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <TextBox Grid.Row="0" TabIndex="1" Width="50" Text="1"/> <TextBox Grid.Row="1" TabIndex="3" Width="50" Text="3"/> </Grid> </Grid>
Any insight on this will be very much appreciated.
Thanks,
Ryan
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Width="100" Height="50">
<RowDefinition></RowDefinition>
<TextBox Grid.Row="0" TabIndex="0" Width="50" Text="0"/>
<TextBox Grid.Row="1" TabIndex="2" Width="50" Text="2"/>
</Grid>
<Grid Grid.Row="1" Width="100" Height="50">
<TextBox Grid.Row="0" TabIndex="1" Width="50" Text="1"/>
<TextBox Grid.Row="1" TabIndex="3" Width="50" Text="3"/>
mrjvdveen
Participant
1937 points
366 Posts
06-30-2009 2:54 AM |
This is not a bug. On each control the default value for TabNavigation is set to Local. This means that it only consideres TabIndexes inside it's direct parent. If you want it to consider all TabIndexes, set the TabNavigation of these controls to Once. Then wrap the outer grid with a ContentControl and set it's TabNavigation to Cycle.
This should give you the behavior you're looking for.
HTH.
06-30-2009 9:30 AM |
Did you actually copy this code into a silverlight compiler? There is no option to add TabNavigation attribute to a grid.
This is a simple interface design. I cannot get this tabbing to work. I believe this is a silverlight bug.
06-30-2009 9:55 AM |
Who's talking about a Grid? It has to be on your input controls. A grid can't have the actual 'focus' needed for tabnavigation.
06-30-2009 10:33 AM |
Check out the code below. I did exactly as you said. It had no effect. Am I misinterpreting what you are saying?
Like I said before, this is a simple xaml model. Its two grids inside of a parent grid. If what you say is correct, can you correct the code?
<ContentControl TabNavigation="Cycle">
06-30-2009 10:43 AM |
In fact you have misinterprited. Where it says TabNavigation="Local" it should say TabNavigation="Once".
06-30-2009 11:01 AM |
I had it at "Once" before but was trying different things and didn't put it back. This still has the same result. I believe this is exactly as you described. Please call me out if something else is missing.
If you are correct in asserting that this is not a silverlight bug, then why dont you post the code to tab through correctly?
06-30-2009 1:40 PM |
I got the solution from a Microsoft Consultant. Tabbing will NOT jump containers on its own. If you need to jump containers on your tabbing, you will need to programatically set the focus of the next element in the sequence.
In this case, I would need to set a LostFocus event on each of the elements. Then in the code behind, set the focus to the element that I needed to tab to.
It seems like there should be an easier way, but I dont believe that there is.