2

I'm new to creating Silverlight applications. I have inherited a code-base that I've been told is using Prism. Based upon what I've seen in the code-base, this looks to be true. My problem is, I am just trying to open a dialog window and close a dialog window.

To open the dialog window, I'm using the following:

  UserControl myDialog = new MyDialog();

  IRegion region = myRegionManager.Regions["DIALOG_AREA"];
  IRegionManager popupRegionManager = region.Add(myDialog, null, true);
  region.Activate(myDialog);

The dialog I have designed appears. It has two buttons: "OK" and "Cancel". When a user clicks on of these dialogs, I want to close the dialog. My problem is, I have no idea how to do this. Because the dialog is not a ChildWindow, I cannot call this.Close(). But, when I change MyDialog to a ChildWindow, it is wrapped in some custom window chrome that i can't figure out how to get rid of.

How do I close a dialog in Prism? Thank you!

Villager
  • 6,569
  • 22
  • 65
  • 87
  • What kind of control is used to wrap the "DIALOG_AREA" region? Is a Region Adapter being used? – Damian Schenkelman Oct 22 '10 at 03:18
  • Could you provide more information about this adapter? Is it the same one used in the Prism Stock Trader RI? The more info you provide the faster anyone will be able to provide an answer. – Damian Schenkelman Oct 22 '10 at 12:48

1 Answers1

0

Instead of putting in a different region, you should make your ViewModel call a service where you call your dialog window.

public MainPageViewModel(IMainPage view,
                            ILoginBox loginBox )
        : base(view)
    {
        this.view = view;
        this.loginBox = loginBox;
}

public interface ILoginBox
{
    void Show();
}

remember to use the IOC container and declare on your ModuleClass:

protected override void RegierTypes()
    {
        base.Container.RegisterType<ILoginBox , LoginBox>();
}

I hope it helps.

If you are still looking for an example, check: another Stackoverflow sample

Community
  • 1
  • 1
Rafael Fernandes
  • 505
  • 6
  • 10