Getting an error when trying to open a Popup Window

Jan 28, 2011 at 8:26 PM


I'm getting the following error, when I try to open a popup window:

'Cannot set Owner property to a Window that has not been shown previously.'

This is the code, I'm using:

            SendLogViewModel sendLogVm = new SendLogViewModel(this._MessageBoxSrv);
            bool? result = _UiVisualizerSrv.ShowDialog("SendLogFilePopup", sendLogVm);

 The _MessageBoxSrv and _UiVisualizerSrv (the required popup is loaded) are correctly initialized. I also use the popup feature in another project and there it works without any problems.

Does anybody has an idea, where I have to search the bug?



Jan 31, 2011 at 7:40 AM
Edited Jan 31, 2011 at 7:42 AM

Can you send me a cut down version of your project that has this issue? I would need very small example, just with it showing the issue ideally, no massive project. The other thing you could do is include Cinch codebase in your solution and step into the IUIVisualizer code to see what the issue is, that maybe your best bet. Or maybe create a new service in your code, which has same code as Cinch IUIVisualizer code and name is something different, and use different interface, and let Meffed supply instance of that, and then you can simply step into your code for new service and see what is up without needing to include Cinch code in your project.


The IUIVisualizer relies on using the Application.Current.MainWindow to set as Owner, is your main window fully shown when you try and show the popup

The code you have pasted above looks ok though.

Jan 31, 2011 at 12:33 PM

Hi Sacha,

thanks for the answer. I tried to include the codebase into my project, but there I did not get any additional information which could help me. But I can send you a Testproject. Could you please provide an email adress, where I can send you the code.



Jan 31, 2011 at 2:54 PM


Jan 31, 2011 at 2:56 PM

Please ensure its a small demo project and clearly tell me which ViewModel has the issue

Feb 1, 2011 at 7:28 AM


You need to send me an actual ZIP file (ie Winzip) I can only open Zip files at that address

Feb 2, 2011 at 9:28 AM

Are you trying to show the popup in the constructor of the viewmodel of the main window? Or somewhere else, before the mainwindow is showed. Thats because cinch sets the owner window to the main window and if it isn't showed already you will get that error.

Feb 2, 2011 at 11:18 AM

Sorry, to keep you out of the discussion. Sacha could find the problem. Here are his findings:

The problem is that the Cinch IUIVizualiser service is trying to set a Owner Window using the Application.Current.MainWindow;

 Which in your case throws this Exception “Cannot set Owner property to a Window that has not been shown previously.” Due to the fact that your MainWindow is no longer shown and it more of a NotifyIcon. To be honest this is strange case.

 To fix it, what I think you need to do, is grab a copy of the Cinch IUIVisualizer service and make your own new interface/implementation based on it, but do not set the owner, or adjust the interface/service implementation such that you can set whether you want an owner to be set when you call ShowDialog().

 This does mean you will not longer be able to use the Cinch.Bootstrapper or the [PopupNameToViewLookupKeyMetadata] attributes, as these both assume they will be writing to the default Cinch IUIVizualiser service.

 Thinking about it, you could also swap out the default Cinch.Bootstrapper, and make that write to your own version of the IUIVizualiser service.

 Anyway there you have it, it is down to your MainWindow no longer being Shown when you try to set owner.

 I’ll amend default Cinch IUIVizualiser service to allow SetParent to be set from ViewModel call, but this wil be done when I have enough changes to warrant a new release.