WPF modess dialog from MS Excel add-in

The WPF form that I run from the WinForms window appears with all text fields as uneditable at startup as a modeless dialog. I used ElementHost.EnableModelessKeyboardInterop to solve the problem and it worked there.

I also open the same WPF interface from MS Excel as an add-in. The EnableModelessKeyboardInterop handle EnableModelessKeyboardInterop not work there. Whenever I try to edit a WPF text field, the focus shifts in Excel and keyboard input is displayed in Excel instead of the WPF text field. Any ideas on how to fix this?

PS - This is a continuation of my previous question about SO: The WPF dialog does not allow editing a text field

+6
source share
1 answer

Decided, kindly provided a link: Starting a WPF application with multiple user interface threads

  var thread = new Thread(() => { var wpfWindow = new WPFWindow(); wpfWindow.Show(); wpfWindow.Closed += (sender2, e2) => wpfWindow.Dispatcher.InvokeShutdown(); Dispatcher.Run(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); 
+7
source

Source: https://habr.com/ru/post/887189/


All Articles