WPF Window set Focus

后端 未结 2 559
-上瘾入骨i
-上瘾入骨i 2021-01-02 05:59

I have a WPF Window which I only create one time and then Show() and Hide() several times. Now I am searching a way to set the focus on a element on each Show(). Where and h

2条回答
  •  [愿得一人]
    2021-01-02 06:42

    In WPF there are two main concepts that pertain to focus: keyboard focus and logical focus. Keyboard focus refers to the element that receives keyboard input and logical focus refers to the element in a focus scope that has focus. These concepts are discussed in detail in this overview.

    You can probably write you own ShowHide method by including both Window.Show/Hide and element.Focus functionalities in order to handle both in the same method.

提交回复
热议问题