0

I'm having troubles with trying to show a dialog. The IUIViusalizerService ShowDialog() method produces following error:

The error: "Method 'Show' not found on 'MyView'

The debugger runs to UIVisualizerService.cs to the method below (beginning on line 380 in the cs file):

protected virtual bool? ShowWindow(FrameworkElement window, bool showModal)
{
        if (showModal)
        {
            var showDialogMethodInfo = window.GetType().GetMethodEx("ShowDialog");
            if (showDialogMethodInfo != null)
            {
                // Child window does not have a ShowDialog, so not null is allowed
                return showDialogMethodInfo.Invoke(window, null) as bool?;
            }

            Log.Warning("Method 'ShowDialog' not found on '{0}', falling back to 'Show'", window.GetType().Name);
        }

        var showMethodInfo = window.GetType().GetMethodEx("Show");
        if (showMethodInfo == null)
        {
            string error = string.Format("Method 'Show' not found on '{0}', cannot show the window", window.GetType().Name);
            Log.Error(error);

            throw new NotSupportedException(error);
        }

       showMethodInfo.Invoke(window, null);
       return null;
    }

My calling code:

public MainWindowViewModel()
    {
        ViewModels.MyViewModel mv = new MyViewModel();

        var ui = GetService<IUIVisualizerService>();
        ui.ShowDialog(mv)
    }

Questions: 1. Am I supposed to impliment a "Show()" method in code behind? 2. Is there a different base class for a DialogView and/or DialogViewModel that must be used?

I started having this problem with Catel 3.6

Thank You

1 Answers1

0

Make sure that the view model that you use resolves to a view that derives from DataWindow or a custom Window with the Catel WindowLogic implemented as shown in the documentation.

Geert van Horrik
  • 5,689
  • 1
  • 18
  • 32