# Manipulating Silverlight controls dynamically from IronRuby - is it currently possible?

**URL:** <https://www.ruby-forum.com/t/manipulating-silverlight-controls-dynamically-from-ironruby-is-it-currently-possible/134161>\
**Category:** IronRuby\
**Created:** [April 8, 2008, 2:18pm UTC](https://www.ruby-forum.com/t/manipulating-silverlight-controls-dynamically-from-ironruby-is-it-currently-possible/134161 "2008-04-08T14:18:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [April 8, 2008, 2:18pm UTC](https://www.ruby-forum.com/t/manipulating-silverlight-controls-dynamically-from-ironruby-is-it-currently-possible/134161/1 "2008-04-08T14:18:10Z")

</div>

Hi,

Is it currently possible to add children to an existing Silverlight  
control  
from the ruby code side ? (like in the IronPython version seen on  
[http://www.voidspace.org.uk/ironpython/webide/webide.html](http://www.voidspace.org.uk/ironpython/webide/webide.html) - great stuff  
btw  
Michael!)

And an extra question: is the Button control available from the  
silverlight  
build on [http://dynamicsilverlight.net](http://dynamicsilverlight.net) ?

cheers,

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [April 8, 2008, 2:28pm UTC](https://www.ruby-forum.com/t/manipulating-silverlight-controls-dynamically-from-ironruby-is-it-currently-possible/134161/2 "2008-04-08T14:28:14Z")

</div>

Hi

Yes the button control is available. The code that goes with that blog  
post  
uses a button. I want to improve that code still because you can do more  
with IronRuby than that. I just need some time to do it.

> **[An IronRuby Digg Client - Ivan Porto Carrero](http://flanders.co.nz/2008/04/06/an-ironruby-digg-client/)**
>
> Search form Recent Posts Scalatra 2.2 released Json4s: One AST to rule them all. Typeclass based databinding for scalatra searchable sbt wiki work …

Basically you need to add the assemblies System.Windows.Controls and  
System.Windows.Controls.Extended to your app folder. You can find those  
assemblies in program files\microsoft sdks\Silverlight\v2.0  
You also need to add a AppManifest.xaml file to your app folder and that  
should contain:  
  
\<Deployment.Parts\>

```
</Deployment.Parts>

```

from then on you can use the button control but you still need to add  
the  
namespace to your xaml file. I have this for a button.  
\<UserControl x:Class=“System.Windows.Controls.UserControl”  
xmlns=“[http://schemas.microsoft.com/client/2007](http://schemas.microsoft.com/client/2007)”  
xmlns:x=“[http://schemas.microsoft.com/winfx/2006/xaml](http://schemas.microsoft.com/winfx/2006/xaml)”

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

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

> 

hth  
Ivan

On Wed, Apr 9, 2008 at 12:16 AM, Thibaut BarrÃ¨re  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [April 8, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/manipulating-silverlight-controls-dynamically-from-ironruby-is-it-currently-possible/134161/3 "2008-04-08T14:43:34Z")

</div>

Hi Ivan,

thanks a lot for all this, that will definitely be useful!

> Is it currently possible to add children to an existing Silverlight  
> control from the ruby code side ?

Any hint most welcome on that point too !

cheers

– Thibaut

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [April 25, 2008, 5:34am UTC](https://www.ruby-forum.com/t/manipulating-silverlight-controls-dynamically-from-ironruby-is-it-currently-possible/134161/4 "2008-04-25T05:34:34Z")

</div>

Hey Thibaut, sorry for the very delayed response …

Every Silverlight object you place on a page is sandboxed, so other  
Silverlight objects cannot access each other. So a Silverlight  
greasemonkey-esk thing isn’t really possible. =( When you create a  
Silverlight object, you implicitly say whether you want to use the  
Silverlight 1 or Silverlight 2 behavior with the ‘source’ attribute;  
when you give it a XAML file:

You’re saying you want to use Silverlight 1, which bypasses the CLR and  
gives you JavaScript programmability of the Silverlight visual elements.  
However, when you give it a xap file:

You’re saying you want to use Silverlight 2, which gives you Ruby,  
Python, C#, etc. Unfortunately, there’s no way to combine these “modes”,  
so you can have native JavaScript and .NET languages both manipulating  
the Silverlight control. However, if you’re just using HTML, you _can_  
use Ruby to monkey-patch the page. =)

Hope that answers your questions,  
~Jimmy

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Tuesday, April 08, 2008 5:42 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Manipulating Silverlight controls  
dynamically from IronRuby - is it currently possible ?

Hi Ivan,

thanks a lot for all this, that will definitely be useful!

> Is it currently possible to add children to an existing Silverlight control from the ruby code side ?

Any hint most welcome on that point too !

cheers

– Thibaut
