Author Topic: property binding and read only properties  (Read 6160 times)

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
property binding and read only properties
« on: May 22, 2014, 10:06:37 AM »
Hi,

I am finding that I can't set a read only property as the source of a property binding.

ie. if the component I try use as a source has the following read only property:
   
  1. public string LevelDescription {
  2.                 get {
  3.                                 return "Lv." + _Level;
  4.                 }
  5.         }
LevelDescription wont appear in the dropdown in the source property binding component in the editor.

if I change it to:
       
  1. public string LevelDescription {
  2.                 get {
  3.                                 return "Lv." + _Level;
  4.                 }
  5.                 set {}
  6.         }
then that property is now available in the dropdown of available properties and fields.

Bug or as per design?  (I can imagine that it might be a requirement for bi-directional data binding but that's something I may not be using)

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: property binding and read only properties
« Reply #1 on: May 22, 2014, 04:06:19 PM »
It's by design.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: property binding and read only properties
« Reply #2 on: May 22, 2014, 04:09:30 PM »
ok

may I ask why is that is by design?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: property binding and read only properties
« Reply #3 on: May 22, 2014, 04:21:01 PM »
Because I want the flow of data to be bi-directional. It just simplifies things.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: property binding and read only properties
« Reply #4 on: May 22, 2014, 04:31:27 PM »
just so you know it means it's extra code for everyone who doesn't need the bidirectional functionality...
(and writing set{} in properties just looks messy)

also I didn't think it actually supported properties until I looked under the hood