Skip to main content

Microsoft Silverlight

Answered Question Tabbing in Silverlight (is this a bug)RSS Feed

(0)

Nikotromus
Nikotromus

Member

Member

1 points

25 Posts

Tabbing in Silverlight (is this a bug)

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>

mrjvdveen
mrjvdveen

Participant

Participant

1937 points

366 Posts

Re: Tabbing in Silverlight (is this a bug)

 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.

-------------
Please mark a post as answer if it answers your question.
Visit my blog: http://jvdveen.blogspot.com

Nikotromus
Nikotromus

Member

Member

1 points

25 Posts

Re: Tabbing in Silverlight (is this a bug)

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.

mrjvdveen
mrjvdveen

Participant

Participant

1937 points

366 Posts

Re: Tabbing in Silverlight (is this a bug)

 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.

-------------
Please mark a post as answer if it answers your question.
Visit my blog: http://jvdveen.blogspot.com

Nikotromus
Nikotromus

Member

Member

1 points

25 Posts

Re: Tabbing in Silverlight (is this a bug)

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">

<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" TabNavigation="Local" TabIndex="0" Width="50" Text="0"/>

<TextBox Grid.Row="1" TabNavigation="Local" 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" TabNavigation="Local" TabIndex="1" Width="50" Text="1"/>

<TextBox Grid.Row="1" TabNavigation="Local" TabIndex="3" Width="50" Text="3"/>

</Grid>

</Grid>

</ContentControl>

mrjvdveen
mrjvdveen

Participant

Participant

1937 points

366 Posts

Re: Tabbing in Silverlight (is this a bug)

 In fact you have misinterprited. Where it says TabNavigation="Local" it should say TabNavigation="Once".

HTH.

-------------
Please mark a post as answer if it answers your question.
Visit my blog: http://jvdveen.blogspot.com

Nikotromus
Nikotromus

Member

Member

1 points

25 Posts

Re: Tabbing in Silverlight (is this a bug)

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?

 <ContentControl TabNavigation="Cycle">

<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" TabNavigation="Once" TabIndex="0" Width="50" Text="0"/>

<TextBox Grid.Row="1" TabNavigation="Once" 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" TabNavigation="Once" TabIndex="1" Width="50" Text="1"/>

<TextBox Grid.Row="1" TabNavigation="Once" TabIndex="3" Width="50" Text="3"/>

</Grid>

</Grid>

</ContentControl>

Nikotromus
Nikotromus

Member

Member

1 points

25 Posts

Answered Question

Re: Re: Tabbing in Silverlight (is this a bug)

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.

 

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities