简体   繁体   English

LiveBindings TObjectBindSourceAdapter

[英]LiveBindings TObjectBindSourceAdapter

I was playing arround with LiveBindings but I cant make TObjectBindSourceAdapter to work.我在玩 LiveBindings,但我不能让 TObjectBindSourceAdapter 工作。 I doesn't change the properties on my object.我不会更改对象的属性。 I've also tried this example .我也试过这个例子 Same problem.同样的问题。

I have a FMX application, with only a checkbox on the form我有一个 FMX 应用程序,表单上只有一个复选框

Then I've made a simple class:然后我做了一个简单的类:

  TSettings = class
  private
    FTest: Boolean;
    procedure SetTest(const Value: Boolean);
  public
    property Test: Boolean read FTest write SetTest;
  end;

{ TSettings }

procedure TSettings.SetTest(const Value: Boolean);
begin
  FTest := Value;
end;

Then I've made the binding using the designer:然后我使用设计器进行了绑定:

在此处输入图片说明

I've created the adapter:我已经创建了适配器:

procedure TFormMain.PrototypeBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
begin
  ABindSourceAdapter := TObjectBindSourceAdapter<TSettings>.Create(Self, TSettings.Create, True);
end;

And added an OnChangeEvent to the CheckBox:并在 CheckBox 中添加了一个 OnChangeEvent:

procedure TFormMain.CheckBox1Change(Sender: TObject);
begin
  TLinkObservers.ControlChanged(Sender as TComponent);
end;

But if I set a breakpoint in SetTest it never gets there.但是如果我在SetTest设置断点,它永远不会到达那里。

What am I missing?我错过了什么?

The project can be downloaded here该项目可以在这里下载

I know this is quite weird if you have already your PrototypeBindSource AutoPost property set to True, but you have to explicitly set (start edit) the related TBindSourceAdapter (end edit) by code in your procedure TFormMain.PrototypeBindSource1CreateAdapter, with我知道如果您已经将 PrototypeBindSource AutoPost 属性设置为 True,这很奇怪,但是您必须通过程序 TFormMain.PrototypeBindSource1CreateAdapter 中的代码显式设置(开始编辑)相关的 TBindSourceAdapter(结束编辑),使用

ABindSourceAdapter.AutoPost := true;

Besides, what is your Link component class?此外,您的 Link 组件类是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM