自定义组件属性LiveBindings

时间:2016-06-12 23:12:55

标签: delphi firemonkey livebindings

我遇到了将字符串属性绑定到TLabel的问题。

TGotManager = class(TComponent)
..
..
published
  property HotQ1: String read FHotQ1 write SetHotQ1;
  property HotQ2: string read FHotQ2 write SetHotQ2;
..

我确实创建了一个组件,因为我不想使用TPrototypeDatasource。

我的目标是通过设计器将两个属性绑定到TLabel.text

我在答案的帮助下做到了这一点:Delphi: Making a component visible to live binding

示例1:

//with this only HotQ1 is bindable via the designer.
[ObservableMember('HotQ1')] 
TGotManager = class(TComponent)

示例2:

//with this only HotQ2 is bindable via the designer.
[ObservableMember('HotQ1')] 
[ObservableMember('HotQ2')] 
TGotManager = class(TComponent)

问题是我只能通过设计器绑定一个属性。拖动该属性时,其他兼容的属性会亮起绿色。拖动第二个属性时,其他属性保持红色。

1 个答案:

答案 0 :(得分:0)

我没有使用一个属性来处理visual Livebindings。我确实通过以下方式开始工作:

http://docwiki.embarcadero.com/RADStudio/Seattle/en/The_Entire_Project_and_Observing_the_Results

还可以从澳大利亚用户组进一步参考和自动化该页面:http://www.adug.org.au/technical/vcl/using-livebindings-to-connect-the-ui-to-objects/

我不接受这个作为答案,因为这并没有解决问题。它提供了一种解决方法。