Silverlight Business Application Themes - ErrorWindow Issues

If you're using the Silverlight Business Application template, you may have noticed some issues, particularly if you have tried the recently-released Silverlight 4 Theme Refresh:

http://www.microsoft.com/downloads/details.aspx?FamilyID=e9da0eb8-f31b-4490-85b8-92c2f807df9e&displaylang=en

The text in the OK button is cropped in the new Themes. This is because the Button is defined with fixed Height and Width. Changing these attributes to MinHeight and MinWidth deals with that problem.

<Button

x:Name="OKButton"

Grid.Row="3"

Click="OKButton_Click"

MinWidth="75"

MinHeight="23"

HorizontalAlignment="Right"

Margin="0,10,0,0"

TabIndex="0"

Content="{Binding Path=ApplicationStrings.OKButton, Source={StaticResource ResourceWrapper}}" />

Also, the Binding to text Resources does not work as expected. This is because the ErrorWindow expects the ResourceWrapper class to expose an ErrorResources property, which it doesn't. This is another simple fix.

public sealed class ResourceWrapper

{

private static ApplicationStrings applicationStrings = new ApplicationStrings();

private static SecurityQuestions securityQuestions = new SecurityQuestions();

private static ErrorResources errorResources = new ErrorResources();

/// <summary>

/// Gets the <see cref="ApplicationStrings"/>.

/// </summary>

public ApplicationStrings ApplicationStrings

{

get { return applicationStrings; }

}

/// <summary>

/// Gets the <see cref="SecurityQuestions"/>.

/// </summary>

public SecurityQuestions SecurityQuestions

{

get { return securityQuestions; }

}

/// <summary>

/// Gets the <see cref="ErrorResources"/>.

/// </summary>

public ErrorResources ErrorResources

{

get { return errorResources; }

}

}

I tweaked the 3 new Themes, then repackaged them in the original ZIP format. Simply UnZIP the attached file and follow the original instructions to deploy them to Visual Studio 2010.

(Note: I also changed App.xaml.cs to always show the ErrorWindow if an UnhandledException occurs).

No Comments