Silverlight XAPs and Web Sites - Page 3
       by kirupa  |  16 April 2008

In the previous page, you learned how to create a new Silverlight project and link a Web site to its output. In this page, let's look at the other case where you already have a Silverlight project created but don't have a Web site associated with it.

Adding a Web Site to Existing Silverlight Project
You may be wondering how you could get into a situation where you have a Silverlight project but no Web site project. It's actually quite common. Currently, in the beta version of Blend 2.5, if you happen to create a new Silverlight project, you create just a Silverlight project. You don't get the option of having a Web site created as well.

Fortunately, the fix for this is quite simple. Open your Silverlight project in Visual Studio. Look in your Solution Explorer where you only see your single Silverlight project:

[ the Solution Explorer is your friend ]

Right click on your Solution and go to Add | New Web Site:

[ you can easily add a new Web site project to an existing solution ]

The Add New Web Site window will appear. You will see several preconfigured Web site templates for you to pick from. Let's keep it simple and just go with the Empty Web Site:

[ select the Empty Web Site template ]

Once you select your Empty Web Site template and hit OK. Your Add New Web Site window will close, and you will see your Web site project appear in your Solution Explorer. Since it is after all an empty Web site, you won't see much.

Anyway, right click on your web site project in the Solution Explorer, and from the menu that appears, select the Start Options item:

[ to associate your Silverlight app during startup with your web site, go to Start Options ]

A properties window will appear. From this window, click on the Silverlight Applications menu item:

[ select the Silverlight Applications tab ]

Once you have clicked on Silverlight Applications, you will probably a lot of empty space on the right-half of this window. At the bottom, though, you will see three buttons of which only one is enabled - Add. Click on this Add button:

[ Add a new Silverlight Application reference ]

Once you have clicked on Add, you will see the Add Silverlight Application dialog appear:

[ create a new SL project or link to an existing SL project form this page ]

From this window, you can either select an existing Silverlight Application (which is what you would probably want to do), or you can create a Silverlight project and have it be linked to your web site instead.

In either case, now, you are at exactly where we were in the previous page where your solution now contains both a Silverlight project as well as a Web Site project that listens to the output produced by your Silverlight project. Yay!


Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

 

1 | 2 | 3




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.