* You are viewing the archive for June, 2010

INotifyPropertyChanged implementations: An Overview


One of the cornerstones of MVVM is the INotifyPropertyChanged interface. This post describes several implementations that have been used/proposed over time.

Table of contents


One of the cornerstones of MVVM is the INotifyPropertyChanged interface. This post describes several implementations that have been used/proposed over time.

The basic ingredient of each INotifyPropertyChanged implementation is the … Continue Reading

Silverlight DataContext Changed Event and Trigger

Silverlight does not provide a DataContextChanged event. Several solutions have been created for this problem. The solution presented here is based on two attached properties instead of one. The advantage of this solution is that multiple event handlers can be attached and this solution does not force the developer to implement a specific interface like the solution presented here.

The heart of the solution consists of the static class DataContextChangedHelper. This class uses the attached property named InheritedDataContext which is bound to the DataContext of the FrameworkElement. Whenever the DataContext is changed, the value of InheritedDataContext (due to the binding) … Continue Reading

Localization of XAML files in Silverlight

This post describes a walk-through of the steps to perform in order to localize XAML files in Silverlight. This post is based on Silverlight 4, but all the steps do also apply to Silverlight 3. The full source code of the resulting project can be downloaded here. The language C# is used throughout this post, but the steps are easy translatable to VB.NET.

First create a Silverlight application solution using Visual Studio 2010 named LocalizationWalkThrough and close the solution after it has been created. Now open the project file LocalizationWalkThrough\LocalizationWalkThrough.csproj with your favorite text editor, and locate the tag SupportedCultures. … Continue Reading

Passing parameters to a Silverlight XAP application

In this post two ways to pass parameters to an in-browser Silverlight application without modifying the XAP are described:

  • Using the querystring of the containing HTML/ASP.NET page
  • Using the InitParams attribute of the object tag that hosts the XAP file

The first method is straight forward: just add a querystring to the URL. You can retrieve the querystring using the HtmlPage.Document like this (based on code from MSDN):

private void Application_Startup(object sender, StartupEventArgs e)
Page p = new Page();
this.RootVisual = p;

// This assumes that Page.LayoutRoot exists and is a StackPanel.
Continue Reading

Code generators for generating strongly typed resource classes for Visual Studio 2010

Guy Smith Ferrier created some code generators for use with Silverlight. Unfortunately, as noted by Don Ruiter these generators do not install in Visual Studio 2010. In this blog he outlines the steps to modify the installer to work with Visual Studio 2010.

Because he did not post the resulting installer, I have performed these steps myself. The resulting installer can be downloaded here.


As can be read here Guy Smith Ferrier has updated his downloads, so the resulting installer can be downloaded here too.

Determining leaked objects

A while back I noticed that Pochet.NET was suffering from a memory leak, probably caused by some event handlers that were not properly removed. Although I had a hunch about what objects were leaking, I was not quite sure. That is why I decided to create the MemoryLeakDetector helper class. The sole purpose of this class is to keep track of how many instances of a specific type are active (i.e. not garbage collected).

This class can be used in the following ways: you can use the MemoryLeakDetector as the base class, like this:

public class MyClass : MemoryLeakDetector
Continue Reading

Forcing the browser to use the latest XAP file

During the development of Pochet.NET I have noticed that sometimes during debugging sessions the browser is not using the latest build of the XAP file but rather the one that is stored in the browser cache. This problem can be solved by appending a querystring to the URL of the XAP file and change this query string on every build. The following code does that by appending the time of the XAP file to the URL of the XAP file.

protected override void OnLoad(EventArgs e)
Continue Reading

Hello Pochet.NET!

Pochet is an ongoing project in which a framework for line-of-business application is developed. This framework has had many incarnations (Clipper, VB6, ASP.NET) and is successfully used in quite a few applications. Sometime ago the decision has been made to rebuild this framework in Silverlight and release it as open source.

This blog is about the development of this new version and everything of interest related to it.