Using the same WPF application for standalone and on web
I have an XBAP (WP开发者_如何学运维F on browser) application that I want to run as a standalone application and also in the browser. How can I do that without making a lot of code changes, since going forward we will be doing a lot of modifications to the code anyway. And it is not a good idea to maintain 2 different codebases for that.
I would have 2 Projects under one Solution. One for Project.Web
and one for Project.Desktop
. Assuming you already have Project.Web
underway and are adding Project.Desktop
as new, use Visual Studio's "Add As Link" when adding files from Web
to Desktop
. This will maintain 1 copy of each file.
Host your main UI in a UserControl
, then add that UserControl
to the Project.Web.Page1
(or whatever it's called) and Project.Desktop.MainWindow
. If you modularize your program sufficiently, you won't have to worry about maintaining 2 projects since they will both be thin shells atop your main UserControl
.
精彩评论