WPF: How to disable tab navigation without also disabling arrow key navigation?

后端 未结 2 1788
清酒与你
清酒与你 2021-01-12 01:52

I have set IsTabStop to false on all controls in my window, so that when I press the Tab key, the focus doesn\'t move (I need the Tab key for something else). B

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 02:44

    I believe what you want is to set the KeyboardNavigation.TabNavigation attached property to Once on your ListView. I've done this with a templated ItemsControl and it seems to give me the behavior that I would expect from like a ListBox where a tab into the control will select the first item but an additional tab will tab right out of the listbox and onto the next control.

    So following this method your example may be able to be shortend down to just this.

    
    

    I haven't tested this with the ListView control however but I wouldn't be surprised if it works for you.

提交回复
热议问题