# Data Binding to IronRuby Objects in WPF

**URL:** <https://www.ruby-forum.com/t/data-binding-to-ironruby-objects-in-wpf/172288>\
**Category:** IronRuby\
**Created:** [July 18, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/data-binding-to-ironruby-objects-in-wpf/172288 "2009-07-18T18:12:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 18, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/data-binding-to-ironruby-objects-in-wpf/172288/1 "2009-07-18T18:12:25Z")

</div>

Hi there,

I’m trying to databind IronRuby objects to a WPF listbox with no success

My data is a Ruby array of objects. The array seems to be bound fine as  
I see the expected number of rows in the listbox. However, every object  
within the array fails to bind correctly. I tried the object to be a  
Ruby hash or a custom class without successâ€¦ WPF wouldn’t display the  
correct value.

When I tried to create an array of CLR classes, it worked.

Will it work in the future?

Thanks,  
Shay.

* * *

Shay F.  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

---

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 20, 2009, 7:45pm UTC](https://www.ruby-forum.com/t/data-binding-to-ironruby-objects-in-wpf/172288/2 "2009-07-20T19:45:13Z")

</div>

Hi,

Well I reply in the forum even though I don’t see the entire thread here  
for some reason. My emails do not reach the mailing list as well, so…

Anyway, Curt - thanks for the clarification. What you’ve described works  
good with binding of textblocks and links, but when I try to bind an  
image to an IronRuby class attribute it doesn’t work (this works with an  
equivalent C# class).

Is it a bug?

## Thanks for the help! Shay.

Shay F.  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

---

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 20, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/data-binding-to-ironruby-objects-in-wpf/172288/3 "2009-07-20T21:53:08Z")

</div>

I return a String. I have three attributes, all of them hold strings.

Textblock that I bind to the strings work, but when I bind an Image  
element (the Source value) to the string, it doesn’t work.

## Shay.

Shay F.  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

---

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 21, 2009, 7:48pm UTC](https://www.ruby-forum.com/t/data-binding-to-ironruby-objects-in-wpf/172288/4 "2009-07-21T19:48:31Z")

</div>

Hi,

I’ve found a workaround that works - because it’s a string, I convert it  
to a clr string before setting the attribute (str.to\_clr\_string).

Then the picture is bound just fine.

## Shay.

Shay F.  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)
