[Ironruby-core] Data Binding?

Ivan Porto Carrero ivan at flanders.co.nz
Fri Aug 15 16:02:17 EDT 2008


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

<window>
<textbox text="{Binding [MyName]}" />
</window>

or
view_proxy.data_context = vm

<window>
<textbox text="{Binding Objects[MyName]}" />
</window>

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 Clark Hess <seanhess at gmail.com>

> 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
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>


-- 
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080815/ce616833/attachment-0001.html>


More information about the Ironruby-core mailing list