[IronPython] Silverlight 2 Controls

Dino Viehland dinov at exchange.microsoft.com
Mon Mar 10 16:51:34 CET 2008


This is a horrible workaround but I think it should work.  You can create the object in XAML, then get the XAML and find the object, then call GetType().Assembly on it, and then pass that off to clr.AddReference.

I'll follow up with the Silverlight guys on our team to make sure we can do better.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Sunday, March 09, 2008 5:22 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Silverlight 2 Controls

Dino Viehland wrote:
> Importing I haven't actually tried, I've only used those controls from XAML.  But you might be able to do clr.AddReference once it's in your manifest and then be able to import.  If that works I think it's something we can probably make automatic.
>
If I add them to the manifest *and* add the following magic to the XAML
then I can read them from XAML:



xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

xmlns:e="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Extended"


I *really* do want to use these from code though. I tried both of the
following forms to add references to the new assemblies:

import clr
clr.AddReference('System.Windows.Controls')
clr.AddReference('System.Windows.Controls.Extended')
from System.Windows.Controls import Button

import clr
clr.AddReference('System.Windows.Controls, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null')
clr.AddReference('System.Windows.Controls.Extended, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null')
from System.Windows.Controls import Button

Both raised the following exception:

IOException: Could not add reference to assembly System.Windows.Controls


Any further suggestions?

Michael


> ________________________________________
> From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord [fuzzyman at voidspace.org.uk]
> Sent: Sunday, March 09, 2008 1:09 PM
> To: Discussion of IronPython
> Subject: Re: [IronPython] Silverlight 2 Controls
>
> Dino Viehland wrote:
>
>> This comes back to the manifest mentioned in the previous question.  You can update the manfiest to contain the additional assemblies which are included w/ the Silverlight SDK.  Those assemblies will get loaded allowing the XAML to parse.
>>
>>
> If I add the following to the XML manifest:
>
>     <AssemblyPart x:Name="System.Windows.Controls.Data"
> Source="System.Windows.Controls.Data.dll" />
>     <AssemblyPart x:Name="System.Windows.Controls"
> Source="System.Windows.Controls.dll" />
>     <AssemblyPart x:Name="System.Windows.Controls.Extended"
> Source="System.Windows.Controls.Extended.dll" />
>
> (Taken from the Silveright controls examples) I *still* can't import
> WatermarkTextBox or Button... I know that it is using this manifest
> because errors in it are reported - or crash IE! :-o
>
> Any other suggestions?
>
> Michael
> htt://www.manning.com/foord
>
>
>
>> ________________________________________
>> From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord [fuzzyman at voidspace.org.uk]
>> Sent: Sunday, March 09, 2008 7:15 AM
>> To: Discussion of IronPython
>> Subject: [IronPython] Silverlight 2 Controls
>>
>> Hello all,
>>
>> I'm adapting a Silverlight 2 controls example for IronPython. It is
>> based on:
>>
>> http://silverlight.net/Samples/2b1/SilverlightControls/run/default.html
>>
>> It seems that the shiny new controls, like Button, ToggleButton,
>> WatermarkedTextBox (etc) don't come 'out of the box' with Silverlight2.
>>  From downloading this example I can see the example includes several
>> dlls - presumably ones that *extend* System.Windows.Controls.
>>
>> As a result XAML that uses elements like these throws parse errors with
>> not-recognised elements. I have these dlls - how do I add them to my
>> IronPython project? If I just add a reference to
>> 'System.Windows.Controls' will it use the new dlls?
>>
>> Thanks
>>
>> Michael
>> http://www.manning.com/foord
>> _______________________________________________
>> 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 Ironpython-users mailing list