Take the 2-minute tour ×

I'm using WAF (Wpf Application Framework) to create a dialog as shown in the ModelView sample application. I am trying to put up a simple AboutBox by mirroring the code for putting up the CreateEmailAccountWizard dialog box. My About box shows up fine the first time, but when I call it again from the menu, it gives me the following exception:

Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.

First, I don't know what this message means. Second, what am I doing wrong? The sample application doesn't throw this exception when you close and reopen the CreateEmailAccountWizard dialog box. My code is nearly identical to it. Any help would be greatly appreciated.

share|improve this question
add comment

1 Answer

Never mind. Found the source of the problem. I was creating a singleton from MEF and it was causing the same dialog instance to run twice. I solved the issue by doing the following:

        var shellView = _container.GetExportedValue<IShellView>();
        _aboutDialogViewModel = _container.GetExportedValue<AboutDialogViewModel>();

I also had to set the MEF attribute on the class to tell it to not use a singleton:

[Export, PartCreationPolicy(CreationPolicy.NonShared)]
public class AboutDialogViewModel : ViewModel<IDialogView>
    public AboutDialogViewModel(IDialogView view) : base(view)
share|improve this answer
add comment

Your Answer


