WPF control not displaying in ElementHost in WinForms app

爱⌒轻易说出口 提交于 2019-11-29 06:33:59

Thanks for replying, but I think you may misunderstand me: I'm trying to use a custom element, whose resources are normally in the Application object, not insert the application itself into the ElementHost.

Fortunately, I've found an answer:

http://drwpf.com/blog/2007/10/05/managing-application-resources-when-wpf-is-hosted/

Short version:

  • Set build action for App.xaml to Page
  • In the code behind for App.xaml create a default constructor that just calls InitializeComponent()
  • When the WinForms app starts up, just create an instance of the App class.

And then it's all good: my WPF control appears as it should.

Now, why is it I only find the answer after I've posted to StackOverflow?

Thanks again,

Bart

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