2014-01-07 18 views
0

如何从SILVERLIGHT Grid XAML中的跳位序列中排除TextBlock。我知道TextBox,我们使用IsTabStop虚假或TabIndex -1,但相同的属性是不缴费的TextBlock停止Tab键序列中的文本块(不是文本框)

我有4所控制,1和4 TextBox(编辑)和2和3是TextBlock(不可编辑)。当我标签时,所有4个都包含在标签序列中。

我想从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> 
+1

怎么可能texblock有焦点..这是不可能的。这就是为什么没有这种可聚焦的财产。一定有东西在后面..如果我错了,请原谅我 –

+0

分享你的XAML,'TextBlock'默认不会获得焦点,所以在这里必须有别的东西在玩。你可能实际上是指“DataGrid”字段而不是单独的TextBlock的/ TextBox的? –

+0

感谢您的帮助。 @Chris,文本框和文本块位于DataGrid中,而不是单独的文本框/块。附加XAML。在开始的时候,我们添加了 user2235485

回答

0

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

<TextBlock KeyboardNavigation.TabNavigation="None"/> 
+0

KeyboardNavigation.TabNavigation属性不存在的Textblock。只有keydown和Keyup存在。 – user2235485

+0

有'WPF'。你在使用Silverlight吗? –

+0

是的..我使用silverlight – user2235485

0

设置调焦=“假”的文本块

+0

不幸的是,该属性不存在textBlock。 – user2235485

0

我想你可能需要在DataGrid列,而不是单元格内容的工作(你的TextBlock),它是集中不是TextBlock中的细胞。

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

或者你可以创建一个行为,要做到这一点....

希望这有助于!