WPF DatePicker 的textbox的焦点
想要判断是否当前DatePicker的textbox获取到焦点, 可以通过以下代码:
private void dtpBirth_TextChanged(object sender, TextChangedEventArgs e)
{
//
IInputElement child = FocusManager.GetFocusedElement(window);
DatePicker dtp = sender as DatePicker;
if (null != child)
{
IInputElement element = dtp.InputHitTest(Mouse.GetPosition(dtp));
if (null != element)
{
dtpBirth.Tag = true;
}
}
}
https://muzizongheng.blog.csdn.net/