[IronPython] Using Silverlight Controls from IronPython (Uhmm... it doesn't look like you can)

John Messerly jomes at microsoft.com
Fri Sep 7 22:25:59 CEST 2007

Sounds like a bug in XAML event binding...

In the Silverlight 1.1 alpha, if the XAML contains an x:Code element, then the XAML parser will always go to DLR/IronPython for event hookup. That is to say, it will never use reflection to hook the event to a statically defined C# method. That is a known limitation.

I thought this behavior was per-XAML file, but from what you're describing it sounds like it's per application.

The only workaround I can think of would be to define a function in your Python code for that event ("PulseStoryboardCompleted"), and then from that function call into the "real" event handler.

Hope this helps,

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Wednesday, September 05, 2007 2:23 PM
To: Discussion of IronPython
Subject: [IronPython] Using Silverlight Controls from IronPython (Uhmm... it doesn't look like you can)

Hello all,

I'm having an issue using Silverlight controls (compiled assemblies)
from C#. Something is going wrong with member name resolution and XAML

I've had this with controls I've created myself, but it also happens
with the sample controls project in the Silverlight 1.1 Refresh SDK.

If you try adding a reference to the 'Button' class and using it from
IronPython, then Silverlight bombs out with the following message:

Exception Details: System.MissingMethodException: Event handler
'PulseStoryboardCompleted' is not defined

PulseStoryBoardCompleted is setup in XAML (embedded as a resource in the
assembly). This exception kills Silverlight - it cannot be caught at the
IronPython level.

To illustrate this, try the following IronPython code:

import clr
clr.AddReference("Silverlight.Samples.Controls, Version=,
Culture=neutral, PublicKeyToken=null")
from Silverlight.Samples.Controls import Button

b = Button()

Any suggestions as to a way round this ?

All the best,

Michael Foord

Users mailing list
Users at lists.ironpython.com

More information about the Ironpython-users mailing list