how to set the ModernDialog.Owner to current/child window

Feb 28, 2014 at 9:33 PM
Hi,

I create new windows on button click and capture position, size when window is closed. The problem is that ModernDialog does not show on the current window but instead on the MainWindow and the user does not see the alert since the calling window is on a second or third monitor.
how can I setthe ModernDialog.Owner to display on center on the calling window. I tried :
if (Application.Current.MainWindow.IsActive)
            {
                this.Owner = Application.Current.MainWindow;
            }
but didn't work. Any help is appreciated.

Thanks
Mar 5, 2014 at 3:55 PM
I modified the constructor to check if window is active and seems to work now.
foreach (Window cWin in Application.Current.Windows)
            {
                if (cWin.IsActive)
                {
                    this.Owner = cWin;
                    break;
                }
            }     
Marked as answer by epasho on 3/5/2014 at 8:55 AM