How do I change from locally generated File in Silverlight to a Website?
Because I want to do things like load images from the web (see this post). To see this in action try creating a Silverlight Project without a website and with a website and past the following into the main page. On the web project things work as expected, in the file based project you get a white screen.
<Grid x:Name="LayoutRoot" Background="White">
<ListBox>
<ListBoxItem>
<Image Source="http://sstatic.net/so/img/logo.png"/>
</ListBoxItem>
<ListBoxItem>
<Image Source="http://sstatic.net/so/img/logo.png"/>
</ListBoxItem>
<ListBoxItem>
<Image Source="http://sstatic.net/so/img/logo.png"/>
</ListBoxItem>
<ListBoxItem>
<Image Source="http://sstatic.net/so/img/lo开发者_运维技巧go.png"/>
</ListBoxItem>
</ListBox>
</Grid>
So I guess I need to move my Silverlight project from using a default file to an http accessible location. How do I move my development files to a website and still be able to compile, debug, etc from Visual Studio. Is the only way to do this create a new Solution as web project and go and Add everything to it?
When you add a Silverlight project to your ASP.NET project it will generate two test pages: one in aspx and one in html.
For a non-ASP.NET website use the html file and everything that it references such as Silverlight.js and the ClientBin directory.
ASP.NET is not required for hosting Silverlight.
I created a new Silverlight project with an ASP net application and used that as my Web application base (copying it to the old Solutions directory and adding it to the Solution). Setting the Web Applicaiton to the starting project and a quick edit to the Silverlight Applications tab of the properties and everything worked. I just take the .html page and the xap from the ClientBin to move it to a live website, and images are working perfectly.
精彩评论