# Data Binding?

**URL:** <https://www.ruby-forum.com/t/data-binding/145987>\
**Category:** IronRuby\
**Created:** [August 15, 2008, 8:55pm UTC](https://www.ruby-forum.com/t/data-binding/145987 "2008-08-15T20:55:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [August 15, 2008, 8:55pm UTC](https://www.ruby-forum.com/t/data-binding/145987/1 "2008-08-15T20:55:17Z")

</div>

Is it possible to use databinding from within IronRuby? In this case, I  
want to have a field, @volume on one class, and listen for changes on  
another class.  
Thanks

---

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [August 15, 2008, 10:04pm UTC](https://www.ruby-forum.com/t/data-binding/145987/2 "2008-08-15T22:04:25Z")

</div>

You can’t databind to DLR objects at the moment. You have to define the  
properties you want to bind to as strong typed classes.

The IronNails project I mentioned earlier tries to alleviate all of that  
🙂

What you can do is define one class in C# to which you want to bind from  
within your control/window  
You can define one property in that C# class something like objects. I  
made  
my properties to be from the type ObservableDictionary

ie.

public class ViewModel : INotifyPropertyChanged  
{

public ObservableDictionary\<string, object\> Objects{  
//implement property  
}  
//implement class  
}

In IronRuby

public MyWindowViewModel \< ViewModel

end

You can then bind to values in the dictionary something like  
vm = MyWindowViewModel.new  
vm.objects[“MyName”] = “The super important text”.to\_clr\_string  
view\_proxy.data\_context = vm.objects

or  
view\_proxy.data\_context = vm

You can index into dictionaries and that way you can get around some of  
it.  
But to bind to properties you need to define those classes in C# at the  
moment unfortunately

Hope this helps somewhat  
Ivan

2008/8/15 Sean C. Hess [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
