Shay Friedman
2009-Jul-18 16:12 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
I believe this will work in WPF 4.0, but it doesn''t work now. WPF 4.0 is supposed to support dynamic objects. I seem to recall Jimmy or Harry (DevHawk) noting this somewhere. Sent from my iPhone On Jul 18, 2009, at 11:12 AM, Shay Friedman <lists at ruby-forum.com> wrote:> 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 t > he > correct value. > > When I tried to create an array of CLR classes, it worked. > > Will it work in the future? > > Thanks, > Shay. > > ---------------------------- > Shay Friedman > http://www.IronShay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
Curt Hagenlocher
2009-Jul-20 14:10 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
This should work under desktop WPF (though not under Silverlight) because IronRuby objects implement ICustomTypeDescriptor. But consider the following code: class Drive def letter ''C'' end def format # format the hard drive end end How do we know what the "properties" of Drive are? For obvious reasons, we would want to return "letter" but not "format". The way I protected against this was to return only those names which have both an arity 0 getter and an arity 1 setter. In other words, the above class would also need a def letter= value # raise some kind of "not supported" exception end in order for the ICustomTypeDescriptor implementation to recognize "letter" as a property. -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman Sent: Saturday, July 18, 2009 9:12 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Data Binding to IronRuby Objects in WPF 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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Ryan Riley ryan.riley at panesofglass.org http://panesofglass.org/ http://wizardsofsmart.net/ On Mon, Jul 20, 2009 at 9:10 AM, Curt Hagenlocher <curth at microsoft.com>wrote:> This should work under desktop WPF (though not under Silverlight) because > IronRuby objects implement ICustomTypeDescriptor. But consider the following > code: > > class Drive > def letter > ''C'' > end > def format > # format the hard drive > end > end > > How do we know what the "properties" of Drive are? For obvious reasons, we > would want to return "letter" but not "format". The way I protected against > this was to return only those names which have both an arity 0 getter and an > arity 1 setter. In other words, the above class would also need a > > def letter= value > # raise some kind of "not supported" exception > end > > in order for the ICustomTypeDescriptor implementation to recognize "letter" > as a property. > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman > Sent: Saturday, July 18, 2009 9:12 AM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] Data Binding to IronRuby Objects in WPF > > 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 Friedman > http://www.IronShay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090720/b932e8c7/attachment.html>
Ryan Riley ryan.riley at panesofglass.org http://panesofglass.org/ http://wizardsofsmart.net/ On Mon, Jul 20, 2009 at 9:16 AM, Ryan Riley <ryan.riley at panesofglass.org>wrote:> > > > Ryan Riley > ryan.riley at panesofglass.org > http://panesofglass.org/ > http://wizardsofsmart.net/ > > > > On Mon, Jul 20, 2009 at 9:10 AM, Curt Hagenlocher <curth at microsoft.com>wrote: > >> This should work under desktop WPF (though not under Silverlight) because >> IronRuby objects implement ICustomTypeDescriptor. But consider the following >> code: >> >> class Drive >> def letter >> ''C'' >> end >> def format >> # format the hard drive >> end >> end >> >> How do we know what the "properties" of Drive are? For obvious reasons, we >> would want to return "letter" but not "format". The way I protected against >> this was to return only those names which have both an arity 0 getter and an >> arity 1 setter. In other words, the above class would also need a >> >> def letter= value >> # raise some kind of "not supported" exception >> end >> >> in order for the ICustomTypeDescriptor implementation to recognize >> "letter" as a property. >> >> -----Original Message----- >> From: ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman >> Sent: Saturday, July 18, 2009 9:12 AM >> To: ironruby-core at rubyforge.org >> Subject: [Ironruby-core] Data Binding to IronRuby Objects in WPF >> >> 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 Friedman >> http://www.IronShay.com >> Follow me: http://twitter.com/ironshay >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090720/cb18e96a/attachment.html>
Ivan Porto Carrero
2009-Jul-20 14:26 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
but wouldn''t linking those to attr_reader, attr_writer and attr_accessor work?At least then you know which things are meant to be properties. I don''t mind using something like clrattr_reader etc. to get a different behavior and something to expand upon. because then it becomes inotify_attr_reader or something, later on for INotifyPropertyChanged implementations. --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero GSM: +32.486.787.582 Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Mon, Jul 20, 2009 at 4:10 PM, Curt Hagenlocher <curth at microsoft.com>wrote:> This should work under desktop WPF (though not under Silverlight) because > IronRuby objects implement ICustomTypeDescriptor. But consider the following > code: > > class Drive > def letter > ''C'' > end > def format > # format the hard drive > end > end > > How do we know what the "properties" of Drive are? For obvious reasons, we > would want to return "letter" but not "format". The way I protected against > this was to return only those names which have both an arity 0 getter and an > arity 1 setter. In other words, the above class would also need a > > def letter= value > # raise some kind of "not supported" exception > end > > in order for the ICustomTypeDescriptor implementation to recognize "letter" > as a property. > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman > Sent: Saturday, July 18, 2009 9:12 AM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] Data Binding to IronRuby Objects in WPF > > 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 Friedman > http://www.IronShay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090720/861bf762/attachment.html>
Curt Hagenlocher
2009-Jul-20 15:01 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
Those are sufficient to flag a member as a property, but not necessary. There are plenty of cases when programmers use a bare method in a place where that they would still want to databind to it. Currently, attr_reader by itself won?t create a ?property?; it also needs the writer. This is arguably a bug. The combination (or attr_accessor) should work. From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ivan Porto Carrero Sent: Monday, July 20, 2009 7:27 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Data Binding to IronRuby Objects in WPF but wouldn''t linking those to attr_reader, attr_writer and attr_accessor work? At least then you know which things are meant to be properties. I don''t mind using something like clrattr_reader etc. to get a different behavior and something to expand upon. because then it becomes inotify_attr_reader or something, later on for INotifyPropertyChanged implementations. --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero GSM: +32.486.787.582 Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Mon, Jul 20, 2009 at 4:10 PM, Curt Hagenlocher <curth at microsoft.com<mailto:curth at microsoft.com>> wrote: This should work under desktop WPF (though not under Silverlight) because IronRuby objects implement ICustomTypeDescriptor. But consider the following code: class Drive def letter ''C'' end def format # format the hard drive end end How do we know what the "properties" of Drive are? For obvious reasons, we would want to return "letter" but not "format". The way I protected against this was to return only those names which have both an arity 0 getter and an arity 1 setter. In other words, the above class would also need a def letter= value # raise some kind of "not supported" exception end in order for the ICustomTypeDescriptor implementation to recognize "letter" as a property. -----Original Message----- From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Shay Friedman Sent: Saturday, July 18, 2009 9:12 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] Data Binding to IronRuby Objects in WPF 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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090720/9cf181aa/attachment.html>
Shay Friedman
2009-Jul-20 17:45 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Curt Hagenlocher
2009-Jul-20 18:21 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
What type of object are you returning? ICustomTypeDescriptor is very incompatible with the semantics of dynamic types. It wouldn''t surprise me that it doesn''t work in certain cases. -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman Sent: Monday, July 20, 2009 10:45 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Data Binding to IronRuby Objects in WPF 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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Shay Friedman
2009-Jul-20 19:53 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Shay Friedman
2009-Jul-21 17:48 UTC
[Ironruby-core] Data Binding to IronRuby Objects in WPF
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 Friedman http://www.IronShay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.