0

I've got Windows.Forms.Form and showing it I set a WPF RibbonWindow to its parent

    public DialogResult ShowDialog(IWin32Window owner)
    {
        DialogResult returnDialogResult = DialogResult.Cancel;
        DummyForm form = new DummyForm(this);
        form.Show(owner);
        ...
        form.Close();
        return returnDialogResult;
    }

After the form.Close() method form closes, but the parent window losts its focus and becomes hided.

Calling the Focus() or the Activate() method of that parent window after that ShowDialog(IWin32Window) method doesn't solve the problem, the main window still hided.

How can I set active and visible the main window?

Miklós Balogh
  • 2,164
  • 2
  • 19
  • 26
  • 1
    You are not documenting your question properly. Surely it isn't actually hidden but *overlapped* by a window from another app? This is caused by re-enabling the owner window too late, consider using the FormClosing event. Or just leave it up to Winforms to find an owner, it's pretty good at finding the right one. – Hans Passant Oct 04 '13 at 11:15

1 Answers1

1

There was a similar question like this yesterday relating to a WPF parent/child Window setup. I couldn't find a way to stop it from happening, but how about just restoring the Window after this happens?:

if (window.WindowState == WindowState.Minimized)
    window.WindowState = WindowState.Normal;

UPDATE >>>

If the Window is not set to WindowState.Minimized, then seeing as you know when this happens, you should be able to do this:

window.WindowState = WindowState.Minimized;
window.WindowState = WindowState.Normal;

UPDATE 2 >>>

If this still doesn't fix your problem, then please take a look at the recent Closing child window minimizes parent post, which now has a couple of further workaround examples.

Community
  • 1
  • 1
Sheridan
  • 68,826
  • 24
  • 143
  • 183