Skip to content

Commit

Permalink
Merge pull request #2569 from cwensley/curtis/wpf-focus-treegridview-…
Browse files Browse the repository at this point in the history
…only-when-window-has-focus

Wpf: only restore focus to TreeGridView after reload when window has focus
  • Loading branch information
cwensley authored Oct 31, 2023
2 parents 0aa16a0 + e3b43f2 commit 5658c89
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Eto.Wpf/Forms/Controls/GridHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public abstract class GridHandler<TWidget, TCallback> : WpfControl<EtoDataGrid,
const double DragScrollFastDelay = 0.01;

ContextMenu contextMenu;
bool hasFocus;
bool hadFocus;
protected bool SkipSelectionChanged { get; set; }
protected swc.DataGridColumn CurrentColumn { get; set; }

Expand Down Expand Up @@ -824,16 +824,16 @@ protected void RestoreColumnFocus()
protected void SaveFocus()
{
SaveColumnFocus();
hasFocus = HasFocus;
hadFocus = HasFocus && Widget.ParentWindow?.HasFocus == true;
}

protected void RestoreFocus()
{
if (hasFocus)
{
if (hadFocus)
Focus();

if (CurrentColumn != null)
RestoreColumnFocus();
}
}

GridColumn GetColumn(swc.DataGridColumn dataGridColumn)
Expand Down

0 comments on commit 5658c89

Please sign in to comment.