문제

I have a stackpanel that keeps getting focus when I tab around in the application.

Using snoop I can see that the stackpanel has a ContentControl which has a ContentPresenter. It is the ContentControl that gets the focus. How can I disable this? And why is this default behavior?

도움이 되었습니까?

해결책

This is not the default behavior, if it has been overwritten by some resource then you can reset it with

KeyboardNavigation.IsTabStop="False"

Or alternatively...

FocusManager.IsFocusScope="False"

다른 팁

Had a similar issue with a DataTemplate that was using a StackPanel as container. The DataTemplate was then used for ListBox items. None of the suggestions worked for me to prevent the items from receiving tab stops, until I used the following on the actual listbox:

KeyboardNavigation.TabNavigation="None"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top