Usage of NavigationService.NavigateDialog(controller)

Mar 18, 2009 at 1:47 PM

I have been trying to get to grips with how to use the NavigateDialog feature.

Problem description:
I navigate to controllerX and a viewX in a non modal way.
From controllerX i then use NavigateDialog to my controllerY with viewY.
I Close() my viewY from controllerY and the code continues to execute in controllerX.
I then use Navigate.GoBack() in controllerY and then I get a unhandled disposed exception in NavigationService.GoBack due to the fact that it tries to do

I get into problems trying to use GoBack when I have closed my modal dialog. The problem is due to the GoBack trying to do hide() on my already closed modal dialog viewY.

I notice in the code for NavigateDialog that it adds the controllerY to the history.

How am I supposed to be using the NavigateDialog function? Should I use the GoBack function instead of Close()-ing the viewY from controllerY.

An example of how to use the NagivateDialog would be great!
Mar 18, 2009 at 2:20 PM
Edited Mar 18, 2009 at 2:32 PM
Hello there,

I think you're right. I never tried before the NavigateDialog method and that scenario can actually happen.

Some changes may be required in the code for that method to work properly.

Something like:

public static DialogResult NavigateDialog(Controller controller)
            string name = controller.Name;

if (!controllerCache.ContainsKey(name))
                controllerCache.Add(name, controller);

            DialogResult res = controller.View.ShowDialog();


            return res;

Since Close() method is called automatically when DialogResult is set in the modal form, there no need to hide the form.
We just call the history.GoBack(), to set the previous controller as the current controller.

But Alex can say more about this :)

Gonçalo Seabra Ferreira
Apr 22, 2009 at 1:38 PM
Thanks, Gonçalo.
I will incorporate the fix soon.