Join  |  Sign in
NullReferenceException in WPF CodeCompletionListBox when used on WinForms ElementHost

24-Nov-2017 10:32 PM

Wolfgang HG

Wolfgang HG

Posts: 21

Hi,

just doing the first steps to integrate the WPF editor control in our app, and found a problem:
The CodeCompletionListBox constructor raises a NullReferenceException. This seems to happen because we have a WinForms app and place the WPF EditorControl on a "System.Windows.Forms.Integration.ElementHost".

The cause of the error seems to be the line
toolTip.PlacementTarget = Application.Current.MainWindow;

==>"Application.Current" is null in our environment.

I think it would be better to find the parent window of the current control.

One more to consider: what about an environment with multiple windows? In this case, "Application.Current.MainWindow" might pick the wrong parent as far as I understand it?

Workaround for me: use the WinForms editor control ;-).

I tried to modify your source code, but it seems I cannot use a self compiled "Alternet.Editor.Wpf.dll" - at least more steps are necessary - do I have to compile all Alternet DLLs myself?


Best regards

Wolfgang
  Reply

28-Nov-2017 10:56 PM

Andrew Medvedev

Andrew Medvedev

Posts: 50

Hi,

Thank you for the bug report.

We have made fix and will include it to the next update, which is expected shortly.

Just wonder why you prefer to use WPF editor hosted in WinForms application rather than using WinForms editor?

regards,
Andrew
  Reply

28-Nov-2017 11:22 PM

Wolfgang HG

Wolfgang HG

Posts: 21

Thanks! But as I use the WinForms control now (and will probably stay with it), the fix is not relevant for us ;-).

The reason to use a WPF control on an ElementHost: WinForms seems to be a bit obsolete, and one day we will have to migrate to WPF or something better. So, if we add a new UI component to our WinForms apps we try to use WPF if possible - this avoids a future migration to WPF.

Best regards

Wolfgang
  Reply

29-Nov-2017 06:28 PM

Andrew Medvedev

Andrew Medvedev

Posts: 50

Hi Wolfgang,

Thank you for the clarification, we've fixed the problem with the WPF editor hosted in WinForms app anyway, and the fix will be included in the upcoming update.

regards,
Andrew

  Reply

29-Nov-2017 07:39 PM

Wolfgang HG

Wolfgang HG

Posts: 21

Thanks!

Best regards
Wolfgang
  Reply