[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 11:09:35 PDT 2007


Well.... it sounds like the new model is going to be a great improvement 
for Python developers on several fronts - buuuuut.... that means every 
online example currently available will be wrong (and I can't write my 
Silverlight chapter until you make the changes) !

:-)

Michael Foord
http://www.manning.com/foord

Jimmy Schementi wrote:
> Michael,
>
> You've got it. The programming model for Silverlight 1.1 C# apps will be similar to WPF (aka. code-first and optional XAML loading). We will be adhering to that general idea, but making it fit right with dynamic languages.
>
> ~Jimmy
>
> ________________________________________
> From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord [fuzzyman at voidspace.org.uk]
> Sent: Friday, September 14, 2007 1:49 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] [python] Re: Using Silverlight Controls from IronPython (Uhmm... it doesn't look like you can)
>
> Ok Jimmy - I'm reassured.
>
> When you say "We're already in the progress of removing x:Code", does
> that mean that the technique for creating Silverlight / IronPython
> applications will change ?
>
> All the best,
>
> Michael Foord
> http://www.manning.com/foord
>
>
> Jimmy Schementi wrote:
>   
>> Michael,
>>
>> Thanks for finding this. Like John said, this is a known issue, however we were not aware it was per application! We are investigating how best to fix this, be it talking to the right people to get the XAML parser updated or removing the dependency on x:Code, whichever comes first. =) We're already in the progress of removing x:Code, since it's the root of this and other Silverlight+DLR integration issues.
>>
>> Rest-assured, using C# controls in a DLR language is a scenario we definitely want to enable!
>>
>> As a "today" work-around, you could do as John suggests, however you can't call into that "real" event handler since it's private. You either have to pass on the event handler (which in this case isn't a big deal as it's just an event to continue the button hover animation), or rebuild the event handler in Python. In this case, it's simply:
>>
>> def PulseStoryboardCompleted(s, e):
>>         s.Begin()
>>
>> For other situations, you have the code for the controls, so building them in Python *should* be trivial. I agree, it's a completely un-ideal solution, but that'll get you working today.
>>
>> ~Jimmy
>>
>>
>>
>>     
>>> -----Original Message-----
>>> From: users-bounces at lists.ironpython.com [mailto:users-
>>> bounces at lists.ironpython.com] On Behalf Of Michael Foord
>>> Sent: Thursday, September 13, 2007 3:22 PM
>>> To: Discussion of IronPython
>>> Subject: Re: [IronPython] [python] Re: Using Silverlight Controls from
>>> IronPython (Uhmm... it doesn't look like you can)
>>>
>>> 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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>         
>>> _______________________________________________
>>> 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
>>
>>     
>
> _______________________________________________
> 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 Users mailing list