我有一个ItemsControl,可以动态创建TextBoxes。当我浏览时,我只希望它专注于一个特定的文本框。
浏览时,焦点应跳到每个Coin_Qty_TxtBx
我一直在尝试使用KeyboardNavigation选项使用其他选项,但是无法使其正常工作。我还尝试手动将文本框上的TabIndex绑定到整数列表。
<ItemsControl x:Name="Coins_LB" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" KeyboardNavigation.TabNavigation="Continue">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Grid.Column="0">
<Button x:Name="CoinPicture_Btn" BorderThickness="0" Background="white" Style="{StaticResource AddRemoveSave_Style}" VerticalAlignment="Top" Height="60" Width="60" HorizontalAlignment="Center" Margin="0,0,0,3" Click="CashPicture_Btn_Click" IsTabStop="False">
<Image Source="{Binding PicturePath}" RenderOptions.BitmapScalingMode="Fant" Margin="-15, -20, -15, -30" />
</Button>
<Label x:Name="Coin_Name_Lbl" Content="{Binding Name}" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="0,1,0,0" VerticalAlignment="Top" Width="72" FontWeight="Bold" Grid.Column="0"/>
<TextBox x:Name="Coin_Qty_TxtBx" Text="{Binding Count, Mode=TwoWay}" Margin="5,2" IsTabStop="True" HorizontalContentAlignment="Center" LostFocus="Cash_Qty_LostFocus" GotKeyboardFocus="Cash_Qty_GotFocus"/>
<TextBox x:Name="Coin_ItemTotal_TxtBx" Text="{Binding Total, StringFormat='c'}" Margin="5,2" HorizontalContentAlignment="Center"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
现在,它将集中在第一个Coin_Qty_TxtBx上,但是从该位置跳动之后,焦点将完全离开ItemsControl。
答案 0 :(得分:0)
您只需要在这些控件上设置IsTabStop="False"
,就不必使用Tab键。
例如:
<TextBox x:Name="Coin_ItemTotal_TxtBx" IsTabStop="False"... />