Unfortunately Silverlight only supports reflection-based data-binding, and does not support ICustomTypeDescriptor data-binding. IronRuby uses ICTD data-binding on the desktop to accomplish accessor binding. To accomplish the same thing in Silverlight you'd need to create a real CLR class and property, inherit from that class, and set the property. You can do this with a precompiled DLL, or maybe IronRubyInline could help: http://github.com/rvernagus/IronRubyInline.
Silverlight 4 will most likely have DLR-based data binding, so you're example would just work. They are also adding something similar to ICustomTypeDescriptor, but for today you'll have to go a bit out of your way. ~js From: [email protected] [mailto:[email protected]] On Behalf Of Shay Friedman Sent: Monday, September 07, 2009 9:45 AM To: [email protected] Subject: [Ironruby-core] Silverlight - Data Binding with IronRuby Types Hi, I'm trying to bind an IronRuby object to Silverlight but I can't get it working. Am I doing something wrong? My object is: class Country attr_accessor :name, :capital_city def initialize(name, capital_city) self.name<http://self.name> = name self.capital_city = capital_city end end and this is the code that does the binding: united_states = Country.new("USA", "Washington D.C") @root.find_name("name_display").data_context = united_states The XAML file looks as follows: <UserControl x:Class="System.Windows.Controls.UserControl" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <StackPanel> <TextBlock>Country name:</TextBlock> <TextBlock x:Name="name_display" Text="{Binding name}"/> <TextBlock>Capital city:</TextBlock> <TextBlock Text="{Binding capital_city}"/> </StackPanel> </UserControl> Any thoughts? Thanks! Shay. ----------------- Shay Friedman Author of "IronRuby Unleashed" http://www.ironshay.com<http://www.ironshay.com/> Follow me: http://twitter.com/ironshay
_______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core
