WPF窗口设置焦点 [英] WPF Window set Focus

查看:130
本文介绍了WPF窗口设置焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF窗口,我只创建一次,然后多次创建Show()和Hide().现在,我正在寻找一种将焦点设置在每个Show()上的元素上的方法.我在哪里以及如何做到这一点?

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 how can I do this?

推荐答案

在WPF中,有两个与焦点有关的主要概念:键盘焦点和逻辑焦点.键盘焦点是指接收键盘输入的元素,逻辑焦点是指具有焦点的焦点范围中的元素.在概述中详细讨论了这些概念.

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.

通过同时包含Window.Show/Hide和element.Focus功能,您可能可以编写自己的ShowHide方法.

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.

这篇关于WPF窗口设置焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆