我有一个“Listview”,如下:
<ListView ItemsSource="{Binding ...}" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="MinWidth" Value="50"/>
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="true">
<Setter Property="IsSelected" Value="true" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding ... }" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
现在焦点使用 CTRL + TAB 组合键导航项目,但我想要处理并替换 TAB 键而不是它。 我怎么能这样做?
答案 0 :(得分:1)
试试这个
<ListView ItemsSource="{Binding Student}" KeyboardNavigation.TabNavigation="Continue" KeyboardNavigation.ControlTabNavigation="None" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="MinWidth" Value="50"/>
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="true">
<Setter Property="IsSelected" Value="true" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Name }" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
设置ListView的KeyboardNavigation.TabNavigation =“Continue”KeyboardNavigation.ControlTabNavigation =“None”。希望这会有所帮助。我已经尝试过它并且有效。