Reference base class event handlers in Windows Phone Silverlight

The short story:

In a Silverlight XAML page it’s not possible to reference an event handler that is defined in the page’s base class.

The long story:

Imagine you have a Windows Phone Silverlight project with (at least) one page that does not directly inherit from PhoneApplicationPage but from a custom base class that is defined within the project. This page base class contains event handler methods. When you register any event in the page’s XAML code and reference one of these event handlers defined in the base class, this will compile without problems. However, when running the App, the page can’t be loaded as a XamlParseException occurs while executing the InitializeComponent() method within the page’s constructor.

The workaround:

The reason for this behavior is a bug in Silverlight’s XAML parser (which, by the way, has been known for years but was never fixed). This is actually good news, because it means you can simply attach the event handler to the according event in codebehind instead of within XAML code, and everything will work fine!