WPF - Switching from WPF app to xbap

别等时光非礼了梦想. 提交于 2019-12-03 13:36:27

问题


I have a working WPF application. I would like to see it running as an xbap. What do I need to change in my WPF app to make it run as an xbap?


回答1:


When it comes to what you can do graphically, the only difference between the two is that XBAP can't use BitmapEffects. Other than that, the sandbox security issues are pretty much the only things you need to deal with. Most pure WPF programs should transition smoothly.

Check out this comparison of the differences between WPF and XBAP.

Here's a tutorial for creating an XBAP application.

Based on that there's a fairly simple refactor you can do to accommodate both WPF and XBAP for your program.

  • First, move all of your WPF code into a .dll project separate from the core WPF EXE project. Reference this project in your core WPF EXE project.
  • Modify the EXE project's App.xaml to point to your main page from your .dll project.
  • Create a new XBAP project.
  • Reference the dll project mentioned above in your XBAP project
  • Modify the XBAP project's App.xaml to point to the main page from your .dll
  • Publish and run.



回答2:


Yes, we can use Windows in XBAP. But the first object must be a Page, because the Page will be displayed on the browser. You can put a button on the page and open your window from it.



来源:https://stackoverflow.com/questions/927688/wpf-switching-from-wpf-app-to-xbap

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