VPet/VPet.Solution/Utils/ClearFocus.cs

17 lines
388 B
C#
Raw Normal View History

2024-03-30 07:00:02 +00:00
using System.Windows;
2023-12-23 14:44:10 +00:00
using System.Windows.Input;
namespace HKW.WPF.Extensions;
public static partial class WPFExtensions
{
/// <summary>
/// 清除元素焦点
/// </summary>
/// <param name="obj">元素</param>
public static void ClearFocus(this DependencyObject obj)
{
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(obj), null);
}
}