locked
Sharing UI between Silverlight & WPF RRS feed

  • Question

  • Hi All,
    I am looking into Silverlight and WPF technologies to revamp our current applications. One question I have is
    We have 2 applications
    1. Web application communicating with Database to read & write data.
    2. Windows application communicating with flat file on the local harddrive to read and write data.
    Both provide the same functionality to the customer.

    Is it possible to create a common code base for both the applications using the silverlight & WPF technologies.

    Thanks

    Friday, September 19, 2008 8:17 PM

Answers

  • Hi...

    I don't know the details about your specific case...but generally yes it is quite possible to have common code base between WPF and SL.  We have an app that shares about 90% common code for the parts that have same functionality.

    One of the first problems you'll encounter is that you can not share DLLs between SL and WPF.  So what we did is create a DLL for WPF (e.g., MyFuncsWPF) and another for SL (e.g., MyFuncsSL).  We store source code in the WPF DLL and in the SL DLL we link back to the WPF source code by using hidden feature in Visual Studio: Add Existing Item --> Add as Link (this is hidden in pull down menu on the Add button!).

    Where there are differences between code bases you can use:
    #if SILVERLIGHT
     // SL specific functionality
    #else
     // WPF specific functionality
    #endif 

    Hope that helps,
    Lynn
    • Marked as answer by Marco Zhou Friday, September 26, 2008 9:08 AM
    Friday, September 19, 2008 11:56 PM

All replies

  • Hi...

    I don't know the details about your specific case...but generally yes it is quite possible to have common code base between WPF and SL.  We have an app that shares about 90% common code for the parts that have same functionality.

    One of the first problems you'll encounter is that you can not share DLLs between SL and WPF.  So what we did is create a DLL for WPF (e.g., MyFuncsWPF) and another for SL (e.g., MyFuncsSL).  We store source code in the WPF DLL and in the SL DLL we link back to the WPF source code by using hidden feature in Visual Studio: Add Existing Item --> Add as Link (this is hidden in pull down menu on the Add button!).

    Where there are differences between code bases you can use:
    #if SILVERLIGHT
     // SL specific functionality
    #else
     // WPF specific functionality
    #endif 

    Hope that helps,
    Lynn
    • Marked as answer by Marco Zhou Friday, September 26, 2008 9:08 AM
    Friday, September 19, 2008 11:56 PM
  • Hi...

    I don't know the details about your specific case...but generally yes it is quite possible to have common code base between WPF and SL.  We have an app that shares about 90% common code for the parts that have same functionality.

    One of the first problems you'll encounter is that you can not share DLLs between SL and WPF.  So what we did is create a DLL for WPF (e.g., MyFuncsWPF) and another for SL (e.g., MyFuncsSL).  We store source code in the WPF DLL and in the SL DLL we link back to the WPF source code by using hidden feature in Visual Studio: Add Existing Item --> Add as Link (this is hidden in pull down menu on the Add button!).

    Where there are differences between code bases you can use:
    #if SILVERLIGHT
     // SL specific functionality
    #else
     // WPF specific functionality
    #endif 

    Hope that helps,
    Lynn
    Friday, September 19, 2008 11:56 PM