Does this do anything?

Dec 9, 2008 at 6:51 PM
I'm playing with Silverlight Loader in a project and I'm not really sure how it works.

So you can load another XAP and other assets and get progress events from them.

But then at the end, you change the plugin source to the new XAP -- so the browser will download it again. It might come from cache, but it might not.

And if you loaded other assets too, you can't pass them directly to the new XAP.

I guess I'm just not sure I agree with using the HTML bridge to replace the XAP entirely. I'd much rather just get my new app as a FrameworkElement, and then a list of Streams for everything else that was loaded, then I can do whatever with that.
Coordinator
Dec 10, 2008 at 10:13 AM
Edited Dec 10, 2008 at 10:24 AM

Hi Endquote,

Unfortunately there is no built in Silverlight solution to write managed code preloaders/splash screens etc.

You might not agree with Microsoft's way of doing things but take a look at their Silverlight Splash Screens developer guide at:

http://msdn.microsoft.com/en-us/library/cc838130(VS.95).aspx

Especially note the following excerpt which is taken from there:

"...You could simulate the same apparent transitional behavior by the following sequence:

  1. Load an initial Source XAML page that is the "splash screen".
  2. Initiate the download of the main source XAML page and any initial resources such as images or videos that the page requires, using Downloader.
  3. As soon as each Downloader raises Completed for all content, change the actual Source value at the HTML DOM level, which unloads the "splash screen" and loads your primary content. The transition is instant at this point because each required element is already preloaded into the browser cache.

"

As for the second part of your comment note that the loader does not automatically switch the source to the new XAP file.

If you prefer to work with the data streams directly, you can use the eventArgs.Result data member which is the data stream of the resource downloaded. It is returned on the downloadCompleteCallback event.

For example you can do something along the lines of:

public void downloadCompleteCallback(Uri packageSource, DownloadCompleteEventArgs eventArgs)
{
     if (eventArgs.Error == null
     {

 

        Assembly assembly = createAssemblyFromStream(eventArgs.Result);

        FrameworkElement fe = (FrameworkElement)

        createObjectFromAssembly(assembly,"MyFrameworkElement");

        ... do something with the framework element...

 

    }
}

I Hope this makes things a little clearer.

  JB

 

Dec 10, 2008 at 4:54 PM
Hi JB, thanks for the reply.

I do disagree with the approach of replacing the XAP in the DOM. While it sounds reasonable in theory, it depends too much on an area of browser functionality which is really an edge case and probably differs in minor ways between browsers and platforms. I'm surprised to see that as a recommended practice.

CreateAssemblyFromStream looks really interesting and seems like a good solution. And I missed the Result property of DownloadCompleteEventArgs. It would be cool to see an example which loads a XAP, some XML and image resources, and initializes them without using the DOM.

Unfortunately I'm out of time on my current project, so I'm just going with the limited SplashScreenSource method to load a single XAP with all its resources embedded. I'll probably look back into this method on the next version.

A couple small suggestions: An event which fires when all items in the download list are completed, rather than one for each. Also you might check out the Bulkloader project for Flash, which has been around a while and offers pretty rich functionality for loading assets. It might be of some inspiration: http://code.google.com/p/bulk-loader/

Thanks again for working on this, it's definitely something SL needs badly.
Coordinator
Dec 11, 2008 at 9:36 AM

Hi Endquote,

Thank you for your comments and suggestions.
I will take a look at the library and I added the new list complete event type as a work item.

 JB

 

Mar 18, 2011 at 6:51 AM

Hi to all!

Especially to you (apijunkie) with best regards to continue working with this project. You developed a great ant useful framework. But I'm fully novice in silverlight and C# and do everything step-by-step according your instructions(Getting started). And see the same problem. After the loader check out persentage of downloading, standart splash screen again shows the loading of main xap. I declare Preloader in initParams.  Please can you comment with more details what you recomended to endquote? In wich files need to make changes, and what exactly changes need?

And a little offtop:) I make my splash screen using your Visual Studio template and now I can't hook up it to my project. Which files of the SilverlightLoader project i must to hook up. As I understand only xap and SilverlightLoader.cs. Am I right? Explain please in more details if not more difficult? 

Sorry for spent your time with dummy questions:) And thanks to you for future answers!