Silverlight 2 Examples and Code Samples from Presentation

Posted by | Filed under ,

As promised, here is the code from last Monday's presentation.

The first of the example applications is a data-entry wizard showcasing dynamic animations, input controls and data binding in Silverlight 2.0. The scenario is that we wanted a new way for the user to enter data in a series of steps that didn't require a series of HTML pages.

A Silverlight 2.0 Wizard Example

You can see it by following this link, and download the code here!

The second application is a mock-video blog that demonstrates the use of markers in video created with Expression Encoder and interaction with the HtmlPage. The idea with this one is that we wanted a way to emphasize advertisement links through animations to increase user interest and, therefore, conversion rates.

A ficticious video blog that promotes the products it reviews.

You can see it by clicking here, and download it by clicking here!

 Also, in reference to the question about passing Silverlight data between pages, someone after the presentation pointed out a very important technique I didn't think to mention, namely the use of isolated storage. Issolated storage is a sandboxed area of the client's file system that you can perform file I/O on from a Silverlight application. Think of it as cookies on steroids: a place where you can read and write information that other domains can't access. It was a very great point I'd be remiss not to mention now!

Thanks to all who attended and participated in the discussion! It was a pleasure getting to present!

*** Now updated from beta for Silverlight 2 release version! ***

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

A Cool Way To Handle ASP.NET Properties Using Nullable Types

Posted by | Filed under , ,

In ASP.NET 1.x, it used to be common to handle the getter of a value type properties thusly:

public int SomeInteger
{
         get
         {
                object val = ViewState["SomeInteger"];
                return val != null ? (int)val : 0;
          }
}

Not bad, but there's more code than needed with nullable types and the "null coalescing operator", anyway. Here's the newer, sleeker way to do the same thing with half the space!

public int SomeInteger
{
         get{ return ViewState["SomeInteger"] as int? ?? 0; }
}

So what's going on in this snippet? Well, we cast the value to a nullable int (int?) which holds a reference to either an int or null then we use the aforementioned ?? operator to return our default value or 0 in the case of null

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5