Solved

Silverlight Tabbing issue

Posted on 2009-06-29
4
731 Views
Last Modified: 2013-11-12
This code tabs perfectly in WPF.  If will not tab in the order of 0, 1, 2, 3 in Silverlight.  Can anyone explain why?  Is this a silverlight bug?  Does anyone know how to fix it.
<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>

Open in new window

0
Comment
Question by:dchau12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Expert Comment

by:TommyTwoPints
ID: 24889052
The problem arose because the TextBoxes with the values 0 & 2 were in different containers to the TextBoxes with the values 1 & 3.

The attached code snippet solves the problem but after the user Tabs past '3' then Silverlight loses focus and it will Tab to the browser.
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
 
        <Grid Grid.Row="0" Width="100" Height="100">
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
                <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"/>
            <TextBox Grid.Row="2" TabIndex="1" Width="50" Text="1"/>
            <TextBox Grid.Row="3" TabIndex="3" Width="50" Text="3"/>
        </Grid>
 
    </Grid>

Open in new window

0
 

Author Comment

by:dchau12
ID: 24894645
Right.  This is what really sucks about silverlight tabbing.  You have to write your containers around tabbing!  How rediculous is that?
0
 
LVL 3

Expert Comment

by:TommyTwoPints
ID: 24902411
It seems to be the same in Windows Forms but not WPF.
0
 
LVL 3

Accepted Solution

by:
TommyTwoPints earned 500 total points
ID: 24902465
You could probably handle this yourself on the by setting the focus of the relevant control on the KeyDown event of the TexBox.

Just create a KeyDown Handler for all textboxes and set the focus based on CType(Sender, TextBox).TabIndex

Please see the code snippet below (For this to work you need to name your textboxes TextBox1, TextBox2, TextBox3 and TextBox4

Tom
    Private Sub TextBoxes_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs) Handles TextBox1.KeyDown, TextBox2.KeyDown, TextBox3.KeyDown, TextBox4.KeyDown
        If e.Key = Key.Tab Then
            e.Handled = True
            Select Case CType(sender, TextBox).TabIndex
                Case 0
                    Me.TextBox3.Focus()
                Case 1
                    Me.TextBox2.Focus()
                Case 2
                    Me.TextBox4.Focus()
                Case 3
                    Me.TextBox1.Focus()
            End Select
        End If
    End Sub

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question