1
我想检测用户何时点击了自定义网格外,但当用户点击网格时,我总是收到LostFocus事件。可聚焦是真实的,但似乎网格从来没有得到关注。有人能帮帮我吗?WPF网格检测点击
public class GridEditor : Grid
{
public GridEditor()
{
Loaded += GridEditor_Loaded;
}
private void GridEditor_Loaded(object sender, RoutedEventArgs e)
{
Focusable = true;
this.LostFocus += new RoutedEventHandler(GridEditor_LostFocus);
}
void GridEditor_LostFocus(object sender, RoutedEventArgs e)
{
if (!this.IsKeyboardFocusWithin && !this.IsMouseOver)
{
Commands.EditConfirmed.Execute(DataContext, this);
}
}
我面对相同的,我需要做一些行动,当用户点击和编辑,因为他希望但当用户点击不同的元素,然后我想排序他已经作出的条目,失去foucs做所需的工作,但它也是当我点击网格以及。你有这个解决方案吗? –