| Comments

Did you know that the Silverlight community site has over 150 Silverlight 2 Beta 2 samples submitted by the community?!  These range from short samples of specific functionality to full-fledged applications that people can use.  I recently spoke of 2 of the multi-file uploader controls that were features in the gallery.  There is a lot of good information being shared by our community.

WE NEED YOUR HELP – UPDATE YOUR SAMPLES!

Today I sent around a note to those who I could identify who had submissions in the gallery with some information pointing them to Silverlight RC0 information and how they can/should prepare their samples to be ready for Silverlight release.  We want to continue to feature your great samples, but need you to have them ready/runnable for Silverlight release.

If you have a sample in the gallery, please make sure that you visit the RC0 information, download the tools, and prepare your application/samples.  Once Silverlight 2 is released, please re-submit them to the gallery so that we can categorize them accordingly.  Older Beta 2 samples will be purged as they will not run once Silverlight 2 releases and we don’t want to aggravate new visitors to the gallery by having stuff that doesn’t work :-).

Here’s what you need to do:

Thanks again for contributing to the community.  If you know of others that have samples, please be sure to pass this information along.  Thanks for helping to spread the word!

| Comments

UPDATE: The supported method for Silverlight 2 release is shown here: http://silverlight.net/learn/learnvideo.aspx?video=69800.  You basically have to make it an assembly resource.

Since the beginning of Silverlight you've been able to embed fonts within a Silverlight application.  The challenge in version 1.0 was that you essentially had to use a downloader and some SetFontSource methods on a TextBlock (for example) to do it.  I wrote about this a while back when using my own handwriting as a font within Silverlight. 

It looked something like this:

this.downloader = control.createObject("downloader");  
this.downloader.addEventListener("completed",
Silverlight.createDelegate(this, this.handleFontDownloaded));
this.downloader.open("GET", "timheuer.ttf");
this.downloader.send();

handleFontDownloaded: function(sender, eventArgs)
{
this.header.setFontSource(sender);
this.itemtext.setFontSource(sender);
this.header.fontFamily = "Tim Heuer Normal";
this.itemtext.fontFamily = "Tim Heuer Normal";
}

It isn't incredibly ideal for all situations.  It works, and in some scenarios might be valid and fine.

For most, I think we'll want an easier implementation and something that feels a bit more natural.  Well, in Silverlight 2, we now have it.  Let's take a look at the above sample and how we could do that for Silverlight 2:

<TextBlock x:Name="Header" FontFamily="timheuer.ttf#Tim Heuer Normal" /> <TextBlock x:Name="ItemText" FontFamily="timheuer.ttf#Tim Heuer Normal" />

Okay, so what is happening here?  What happened to the script?  There is none (obviously).  What is happening here is that Silverlight now does the lifting for you.  Let's break this down a bit more.

First, the FontFamily is set to "timheuer.ttf" in this example, which is my handwriting font in TrueType format.  This font is located next to the applications XAP file which is in ClientBin.  It could be located anywhere in the same application domain and you could use an absolute URL here as well.  For our purposes, we have a file on a web server.

When we set that in the FontFamily to a file, Silverlight essentially creates the downloader for us in an efficient manner.  The font file is requested based on the URI provided and downloaded via a GET request.  Once downloaded it parses out the second part (the "#") to look within that font file for the named font.  So essentially the format is:

<file>#<named-font>

where # is the delimiter in this format.  That's it, you are done.  No script needed.  If you choose to package several font assets within your application you can put them in a single archive file as well and the same syntax would apply:

<TextBlock x:Name="Header" FontFamily="timheuer.zip#Tim Heuer Normal" />

The same execution happens.  Silverlight gets the archive file and then looks at the font file contents in the archive to find the first named font to use.  The archive doesn't have to only have font files either...which is cool at times.

Hope this helps!

| Comments

When working with Silverlight 2, most will be working with managed code (c#, vb, etc.).  But likely people are working with Silverlight as an additive value to their web application, providing some enhanced user experience to an application.  there may be times where you will still need to call back into the hosting html context.  For then, you'll want to be familiar with two objects HtmlDocument and HtmlPage. 

Both of these objects provide access to the page context hosting your silverlight control.  If you need to seek things in the HTML DOM, you could use the HtmlDocument class.  For example, let's say I need to change the innerHTML property of some <div> element:

using System.Web.Browser;

HtmlDocument doc = HtmlPage.Document;
doc.GetElementById("mydiv").SetProperty("innerHTML", "<b>hello world</b>");

Also, i might want to interact with existing client-side functions, perhaps from client-side frameworks or other library utilities you might have developed on your own.  If I have a function on my page called "foo()" I would invoke it like this:

using System.Web.Browser;

HtmlPage.Window.CreateInstance("foo");

And if I had parameters in a function, like "foo2(theAlert)," I would invoke it like this:

using System.Web.Browser;

HtmlPage.Window.CreateInstance("foo2", new string[] { "tim heuer" });

This may not be the norm with your Silverlight project, but I hope this helps clear some things up!  I am including the "using" statements in my c# samples so you know where in the namespace the class library exists.

| Comments

I've gotten a few requests from internal local sales teams, Sharepoint professionals and developers about how to implement Silverlight in Sharepoint.  I usually try to explain that since Sharepoint is essentially an ASP.NET application it is relatively simple to implement.  Of course, that usually doesn't help :-).  What helps is some documentation and samples that show how you would use Silverlight to enhance a Sharepoint experience.

As a part of the Software+Services Blueprints series, a new bundle has been made available to download to provide guidance and source code to help provide some information.  In the blueprint you'll get:

    • A simple “hello, world” sample showing Silverlight in a Web part.
    • A Silverlight slider control as a SharePoint custom field type.
    • A navigation control.
    • A Colleague Viewer that uses lookups in Active Directory by using Windows Communication Foundation.
    • A Silverlight picture viewer from a SharePoint picture library.
    • A visual how-to center, created in Silverlight and based on a SharePoint list, for viewing videos.

A pretty great resource for those wanting to discover implementation details as well as some ideas for Silverlight in Sharepoint!

| Comments

From the 'does the guy ever sleep' category, ScottGu enlightens us all again with a very great tutorial on using Expression Blend 2.5 (March preview coming soon) to work with Silverlight 2 content.

Scott walks through a tutorial on using the design-time features of Expression Blend 2.5 and some tips along the way to produce a chat-like application using Silverlight:

Definitely worth a look to study before MIX.  Someone might want to pull Scott aside about the font choice though...