delphifiremonkeylivebindingsdelphi-10.4-sydney

LiveBindings TObjectBindSourceAdapter


I was playing arround with LiveBindings but I cant make TObjectBindSourceAdapter to work. 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

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:

enter image description here

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:

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

But if I set a breakpoint in SetTest it never gets there.

What am I missing?

The project can be downloaded here


Solution

  • 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

    ABindSourceAdapter.AutoPost := true;
    

    Besides, what is your Link component class?