WPF form in a console app

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 12:12:57

问题


Im running a console app that loads a dll and calls a method from that dll that creates a WPF form. So I'm just calling to Program.Execute() method and it does all the creation of the form. All reflection business goes well, but the form does not appear.

I've been told that this is because a console app does not have a windows message loop, but I'm sure there is a way to simulate that. For example, I tried playing with System.Windows.Threading.DispatcherFrame, but to no avail - the form still does not show up.

Did anyone else face this problem?


回答1:


Just call WPF's Application.Run(). Or Window.ShowDialog(), same thing. You will also have to apply the [STAThread] attribute on your Main() method.



来源:https://stackoverflow.com/questions/3857828/wpf-form-in-a-console-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!