简体   繁体   English

WPF ListView在列标题中带有文本框,选项卡问题

[英]WPF ListView with textbox in column header, tab problem

I got a ListView in WPF with a GridView as view. 我在WPF中得到了一个ListView,并以GridView作为视图。 I wanted to add textboxes to the column headings as filter mechanism. 我想将文本框添加到列标题作为过滤器机制。 But when I set the cursor to the first column heading it does not tab to the next column heading textbox. 但是,当我将光标设置到第一列标题时,它不会跳至下一个列标题文本框。 Instead it goes to the next control after the ListView. 而是转到ListView之后的下一个控件。

Here is the sample: 这是示例:

<ListView>
    <ListView.View>
        <GridView>
            <GridView.Columns>
                <GridViewColumn>
                    <StackPanel>
                        <TextBlock>ABC</TextBlock>
                        <TextBox>YXZ</TextBox>
                    </StackPanel>
                </GridViewColumn>
                <GridViewColumn>
                    <StackPanel>
                        <TextBlock>Spalte Nummer 2</TextBlock>
                        <TextBox></TextBox>
                    </StackPanel>
                </GridViewColumn>
            </GridView.Columns>
        </GridView>                    
    </ListView.View>
</ListView>

How will I make the cursor to tab from the first column header textbox to the second column header textbox? 如何将光标从第一列标题文本框切换到第二列标题文本框?

You should try setting TabIndex properties on your TextBox'es. 您应该尝试在TextBox上设置TabIndex属性。

<TextBox TabIndex="0">YXZ</TextBox>

<TextBox TabIndex="1">Spalte Nummer 2</TextBox>


Edit: You should also set KeyboardNavigation.TabNavigation="Local" on your ListView . 编辑:您还应该在ListView上设置KeyboardNavigation.TabNavigation="Local"

您是否尝试过在每个TextBox上设置TabIndex属性?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM