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
on 15.08.2008 20:55
on 15.08.2008 22:04
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@gmail.com>