[英]How to tab once instead of twice in WPF
I have a simple page that allows me to associate names with bunks.我有一个简单的页面,允许我将名字与铺位相关联。 Unfortunately tab isn't working as I expect.不幸的是,标签没有按我预期的那样工作。 I have to tab once to get to the next item and again to get to the TextBox.我必须按一次 Tab 键才能进入下一个项目,然后再按一次 Tab 键才能进入文本框。 This also occurs if I remove the Label control.如果我删除 Label 控件,也会发生这种情况。 I've searched and searched and tried a bunch of things but can't figure this one out.我已经搜索和搜索并尝试了很多东西,但无法弄清楚这一点。 Any suggestions?有什么建议么? I'm starting to get comfortable with WPF MVVM but I'm no expert.我开始熟悉 WPF MVVM,但我不是专家。
<Page x:Class="DiverBoard.Views.ConfigurePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:DiverBoard.ViewModels"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="800"
Title="ConfigurePage" Background="Navy">
<Page.DataContext>
<vm:TripViewModel/>
</Page.DataContext>
<WrapPanel>
<ListBox Background="Navy" ItemsSource="{Binding Trip.Bunks}" KeyboardNavigation.TabNavigation="Cycle">
<ListBox.Template>
<ControlTemplate>
<DockPanel LastChildFill="True">
<ItemsPresenter></ItemsPresenter>
</DockPanel>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label FontSize="18" Foreground="white" Content="{Binding Value.BunkNumber}" Width="50"></Label>
<TextBox FontSize="18" Text="{Binding Value.DiverName}" Width="200" IsTabStop="true"></TextBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</Page>
Naturally I figured it out right after posting a question by reading something again that I had already read.自然地,我在发布问题后通过再次阅读我已经阅读过的内容来解决这个问题。
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="IsTabStop" Value="False"/>
</Style>
</ListBox.ItemContainerStyle>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.