簡體   English   中英

如何在 WPF 中按一次而不是兩次

[英]How to tab once instead of twice in WPF

我有一個簡單的頁面,允許我將名字與鋪位相關聯。 不幸的是,標簽沒有按我預期的那樣工作。 我必須按一次 Tab 鍵才能進入下一個項目,然后再按一次 Tab 鍵才能進入文本框。 如果我刪除 Label 控件,也會發生這種情況。 我已經搜索和搜索並嘗試了很多東西,但無法弄清楚這一點。 有什么建議么? 我開始熟悉 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>

開始,選項卡,選項卡

自然地,我在發布問題后通過再次閱讀我已經閱讀過的內容來解決這個問題。

    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="IsTabStop" Value="False"/>
        </Style>
    </ListBox.ItemContainerStyle>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM