Reposed from the list (with no replies) just before the forum launch.
This question could easily be just for @Malcolm, but figure others might have some knowledge…
I’m exploring the Fluent LiveBindings offering that Malcolm introduced a while ago.
[GitHub - malcolmgroves/FluentLiveBindings: Simple library to make creating LiveBindings in code much easier.]
The examples are focused on binding a UI TComponent
to either another TComponent
or TBindSourceDB
.
I’m wanting to bind a UI component to a vanilla TObject
instance that serves as a viewmodel to the form.
Example:
TViewModel = class
private
...
public
CompanyName : string read ... write ...;
end;
So a form with an edit field might be bound with:
BindingsList1.BindComponent(CompanyEdit)
.ToComponent(fViewModel, 'CompanyName')
.BiDirectional;
That won’t compile unless I change my vm to…
TViewModel = class(TComponent)
…which works, but without two way support:
For example:
BindingsList1.BindComponent(CompanyEdit)
.ToComponent(fViewModel, 'CompanyName');
As soon as I add .BiDirectional
, it raises an exception:
Project SimpleCodeBindings.exe raised exception class EEvaluatorError with message 'Expected an identifier, number or string.
Unless I’m mistaken, I’m lead to believe that LiveBindings does work with plain objects. Am I missing the obvious? Is that something that could be added to the framework?
ps I don’t want to be confined to using TComponent
descendants as my non-visual view model even if the BiDirectional bit worked.
Any suggestions appreciated.