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

Michael Foord fuzzyman at voidspace.org.uk
Fri Sep 14 00:22:16 CEST 2007


John Messerly wrote:
> 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.
>   

That means I need to know the details of what the XAML is hooking up 
(which I don't) and it also means that I can't use prebuilt controls 
from IronPython which is a major restriction. :-(

Can you apply some gentle pressure in the right places? Jim Hugunin 
showed this working in their Vegas Mix talk - so it would be a shame to 
lose it as basically it means that you can't use IronPython to create 
rich user interfaces except completely from scratch.

All the best,


Michael Foord
http://www.ironpython.info/

> Hope this helps,
> John
>
> -----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
> interactions.
>
> 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=1.0.0.0,
> 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
> http://www.ironpython.info/
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>
>   




More information about the Ironpython-users mailing list