从制表顺序中停止文本块(不是文本框)

时间:2014-01-07 06:37:22

标签: silverlight xaml silverlight-4.0

如何从SILVERLIGHT TextBlock XAML中的标签序列中排除Grid。我知道对于TextBox,我们使用IsTabStop false OR TabIndex -1,但TextBlock无法使用相同的属性

我有4个控件,1和4是TextBox(可编辑),2和3是TextBlock(不可编辑)。当我选项卡时,所有4个都包含在Tabbing序列中。

我想从Tab键中排除2,3(Textblocks)。意思是,如果我从TextBox 1标记,焦点应直接转到TextBox 4.请帮助。

加载= “UserControl_Loaded” >         

              <DataTemplate x:Key="CellEditClientAllocations" >
                     <TextBox Text="{Binding ClientAllocations, Mode=TwoWay}" 
                     Style="{StaticResource GridCellTextBoxStyle}"                         
                     x:Name="tbxClientAllocations"
                     Loaded="TextBox_Loaded" 
                     TextChanged="tbxClientAllocations_TextChanged" 
                     KeyDown="tbxClientAllocations_KeyDown"
                     LostFocus="tbxClientAllocations_LostFocus"
                      GotFocus="tbxClientAllocations_GotFocus"/>
                </DataTemplate>
    <DataTemplate x:Key="CellAccountId">
                        <TextBlock Text="{Binding AccountId, Converter={StaticResource anc}}" Style="{StaticResource GridCellTextBlockStyle}" /> </DataTemplate>
    <DataTemplate x:Key="CellEditAccountId">           
            <TextBox  Text="{Binding AccountId, Converter={StaticResource anc}, Mode=TwoWay}" x:Name="tbxAccountId" LostFocus="TbxAccountIdLostFocus" TextChanged="TbxAccountIdTextChanged" GotFocus="tbxAccountId_GotFocus"/>
    </DataTemplate><DataTemplate x:Key="CellAccountName"> <StackPanel>
                <TextBlock  VerticalAlignment="Center" Text="{Binding AccountName, Mode=TwoWay}" Foreground="{Binding IsAccountValid, Converter={StaticResource cc}}"  kStyle="{StaticResource GridCellTextBlockStyle}" Name="Account" MouseRightButtonUp="" > </TextBlock> </StackPanel> </DataTemplate>       
    <DataTemplate x:Key="CellLotInstructions"> <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding LotInstructions}" Style="{StaticResource GridCellTextBlockStyle}"/>
                <HyperlinkButton Content="Edit" Style="{StaticResource HyperlinkButtonStyleUnderline}" IsEnabled="{Binding LotInstructionsEnabled}" Name="Lotinstructons" HorizontalContentAlignment="Center" MouseLeftButtonDown="LotinstructonsMouseLeftButtonDown"  VerticalContentAlignment="Center" Click="ViewSpecifyLots_Click" Visibility="{Binding LotInstructionsEdit}" /> </StackPanel>  </DataTemplate>

3 个答案:

答案 0 :(得分:0)

尝试将附加属性KeyboardNavigation.TabNavigation设置为

<TextBlock KeyboardNavigation.TabNavigation="None"/>

答案 1 :(得分:0)

为文本块设置Focusable =“False”

答案 2 :(得分:0)

我认为您可能需要处理DataGrid列而不是Cell内容(您的TextBlock),它是Focus的Cell而不是TextBlock。

您可以为CellEnter事件分配一个事件处理程序(可从原始列的定义访问),然后将DataGrids selected cell selected属性设置为false。不是最好的解决方案,但它应该工作。

或者,您可以创建一个行为来执行此操作....

希望这有帮助!