-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ProgressDialog close causes loss of focus on child control #2532
Comments
I don't think it's possible currently: @punker76 Correct me if I'm wrong, but I guess a method like following could help. It's just an idea... public void ResetStoredFocus()
{
restoreFocus = null;
} |
@thoemmi This is maybe a possible solution. Or an additional (public) version of the SetFocus method with a parameter which overrides the stored control... |
@thoemmi Yes, it works! I tested it and focus is given to the child control. |
@dxdx347 2 new methods now available on /// <summary>
/// Stores the given element, or the last focused element via FocusManager, for restoring the focus after closing a dialog.
/// </summary>
/// <param name="thisElement">The element which will be focused again.</param>
public void StoreFocus([CanBeNull] IInputElement thisElement = null)
/// <summary>
/// Clears the stored element which would get the focus after closing a dialog.
/// </summary>
public void ResetStoredFocus() ^ @thoemmi |
Looks good to me 👍 |
What steps will reproduce this issue?
In my app, I'm loading a DocumentViewer for previewing and printing. Because loading can take up to a few seconds, I would like to display a ProgressDialog. The logic is this: display ProgressDialog, create and display DocumentViewer, close ProgressDialog.
The problem is that when closing the dialog, the focus returns to the MainWindow, instead of remaining to the DocumentViewer window. I think it's because the dialog CloseAsync(). I've tried calling Focus(), Activate(), Show(), setting TopMost = true, setting the owner of the child window, but, although the window is initially displayed in front of the parent, the focus still returns to the parent. The only way to I restored the focus to the child was by doing a programmatic click inside the child window, in ProgressDialogController.Closed event, but the disadvantage is that there is an ugly transition (child initially appears in front, then parent, then child again).
Can CloseAsync() be avoided? Or how to close MahApps ProgressDialog without losing focus on child control?
Expected outcome
The ProgressDialog should be closed without losing focus from the child window.
Environment
The text was updated successfully, but these errors were encountered: