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做所需的工作,但它也是當我點擊網格以及。你有這個解決方案嗎? –