Habe es jetzt so implementiert.
Delphi-Quellcode:
type
TBinding =
packed record
GUI: TObject;
DateModelValuePtr: Pointer;
end;
private
Bindings:
array of TBinding;
implementation
AddBinding(EditContentbarStartMarker, @FViewModel.StartMarker);
AddBinding(EditContentbarEndMarker, @FViewModel.EndMarker);
Add Binding
Delphi-Quellcode:
procedure TForm1.AddBinding(GUIComponent: TObject; DateModelValuePtr: Pointer);
var
NewBinding: TBinding;
begin
// Binding Element erstellen
NewBinding.GUI := GUIComponent;
NewBinding.DateModelValuePtr := DateModelValuePtr;
// Neues (globales) Binding erstellen
SetLength(Bindings, Length(Bindings) + 1);
Bindings[ High(Bindings)] := NewBinding;
end;
Refresh Binding
Delphi-Quellcode:
procedure TForm1.BindingRefresh;
var
i: Integer;
Ptr: ^Integer;
begin
for i := 0 to High(Bindings) do
begin
Ptr := Bindings[i].DateModelValuePtr;
(Bindings[i].GUI as TEdit).Text := IntToStr(Ptr^);
end;
end;
entspricht zwar nicht ganz der oben genannten Struktur, aber funktionert.