Shawn Wildermuth


My Rants and Raves about technology, programming, everything else...

Reminder: Atlanta Geek Dinner October 23, 2008

Url: http://www.geekdinners.com/DinnerInstance.aspx?...

Just a quick reminder that Thursday, October 23rd, 2008 is the next Atlanta Geek Dinner in Alpharetta, Georgia.  We are meeting at 6:30pm at:

Using Isolated Storage Settings in Silverlight 2

Here is a quick but fun tip for working with Silverlight 2. I found that many people are using Isolated Storage for saving user preferences or other small pieces of information. When I look at the code, I am surprised by how much trouble they are going through to save small bits of data.  That's where Isolated Storage Settings come in.

For example, let's assume you want to be able to store a FavoriteColor for a user.  You could cruft up a bunch of code to save a file and handle the serialization, or you could use the IsolatedStorageSetting class. This class supports being able to store arbitrary objects in a settings file in Isolated Storage. The IsolatedStorageSettings class supports two keyed collections, ApplicationSettings and SiteSettings. ApplicationsSettings is specific to your .xap file, while SiteSettings are specific to your domain.  Here is an example of a property that uses the IsolatedStorageSettings to store a nullable Color for FavoriteColor:

Atlanta Silverlight Tour Stop Almost Here!

Url: http://silverlight-tour.com

There is still time to register if you want to join me in Atlanta for the first Silverlight 2 Release workshop. I will be guiding the students through the maze of skills required for Silverlight 2 including XAML, Blend, Visual Studio 2008, Web Services, ADO.NET Data Services and even advanced topics like control customization and line-of-business application development.

DevReach Example Code

Url: http://www.devreach.com

I am finally on my way home from Europe and had a great time speaking at both SDC and DevReach. The people in Bulgaria really treated me well. If you were at any of my talks, please see the following code downloads for the demo code:

Minor Pet Peeve

Not a biggie, but just so that anyone that reads my blog knows...its "Silverlight 2", not "Silverlight 2.0". Wasn't my decision, but its the fact. Journalists and bloggers alike have been throwing out "2.0" a lot lately and after being hammered by some well-meaning Microsofties about the name, I just wanted to make sure everyone knows the right way.

'Nuff about that...

Understanding Image and Media Failed Errors

In meeting with a client (Schoolmaster.nl who is building a cool LOB app), we came across the problem of one of their components was throwing Image Failed Javascript errors. Handling them in the App.UnhandledException event didn't help because the errors were surfaced outside the plug-in, directly to Javascript.  Immediately I use the VisualTreeHelper to walk the entire XAML tree (including nested templates) to just add an event handler on to every ImageFailed events to try and suppress these errors. 

public Page()
{
  InitializeComponent();

  Loaded += (s, e) =>
    {
      // Call Recursive method to wire all Image tags
      WireImageFailed(this);
    };
}

void WireImageFailed(DependencyObject source)
{

  for (int x = 0; x < VisualTreeHelper.GetChildrenCount(source); ++x)
  {
    DependencyObject child = VisualTreeHelper.GetChild(source, x);
    if (child is Image)
    {
      ((Image)child).ImageFailed += (s,e)=>
        {
          // NOOP
        };
    }
    WireImageFailed(child);
  }

}

In case you're not familiar with this class, it helps you walk through the entire render tree at runtime (including inside controls and control templates). This means I could look for all the Image objects and handle the event to suppress the error. This worked but it felt hacky and doesn't work for them as they are building a lot of dynamic XAML.

Updating My Sites to Silverlight 2 RTW

I've started updating my sites that use Silverlight 2 to the RTW bits. So far I've got silverlight-tour.com and wildermuth.com updated.  SilverlightData.com will have to wait a few days as I have a completely new example that is more complete and dynamically switches between NHibernate and Entity Framework.  Look for an announcement on that this weekend.

The only caveat I have for updating your site is if you're using the Silverlight ASP.NET Control to host your projects. You can copy the SDK to your server if you want but I found that the upgrade to RTW works seemlessly except that I changed the reference to "CopyLocal=True" so I can copy the control to my server instead of expecting it to be installed on the server.

Silverlight 2 Released!

Url: http://silverlight.net

Its been a long road to release but we're finally there. If you're anything like me and have been through WPF/E, Silverlight 1.0, Silverlight 1.1, Silverlight 2 Beta 1, Beta 2 and RC0, I know you're ready for this thing to hit the streets.

Dirty Little Secrets - Episode 2

Url: http://wildermuth.com/dirtylittlesecrets

My second episode of my "Dirty Little Secrets" screencast is up. This time I show you how to use control templates to skin a complex control in Silverlight 2. I create a ListBox with a Data Template and use ControlTemplates to skin the entire ListBox, Scrollbars, ListBoxItem and all.  Check it out!

ADO.NET Data Services and TimeZone

There is a known problem with ADO.NET Data Services today that is important if you (or your server) lives in specific timezones.  The problem is associated with the way that the Silverlight Data Services Library constructs their URI for searches. 

The problem surfaces if you do a query that has a DateTime comparison in it. For example:


Application Name WilderBlog Environment Name Production
Application Ver 2.0.0.0 Runtime Framework .NETCoreApp,Version=v2.0
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.26020.03
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86