VPet/VPet.Solution/Utils/ClearFocus.cs
2024-03-30 15:00:02 +08:00

17 lines
388 B
C#

using System.Windows;
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);
}
}