2014-01-07 21 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。不是最好的解決方案,但它應該工作。

或者你可以創建一個行爲,要做到這一點....

希望這有助於!