.NET WPF: Problems repeatedly calling WPF form from a WinForm application -
as title states, i'm calling wpf form winform app, (with several classes on call stack between) numerous times. initially, wpf worked once. after googling, found had add shutdownmode.onexplicitshutdown wpf application create.
now, after adding that, upon exiting first wpf form, control never returns 'run' call , focus given winform dialog. if exit that, control returned wpf run.
winform:
application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); mainform form = new mainform(); application.run(form);
wpf pre-init:
application = new system.windows.application { shutdownmode = system.windows.shutdownmode.onexplicitshutdown };
calling wpf form:
confirmform form = new confirmform(); application.run(form);
what going on here?:
application.run
(in both winforms , wpf) blocking call runs message loop , returns when application ready exit.
you should call show()
, shows form
or window
, returns immediately.
however, need call elementhost.enablemodelesskeyboardinterop
tell wpf use winforms message loop.
Comments
Post a Comment