Berlin and DSharp (btw. Sample1 raise except after click Validate button).

Berlin and DSharp (btw. Sample1 raise except after click Validate button).

I have TEdit (edtOne) and some object:

TSomeObject = class
private
fFieldS: string;
protected
function GetFieldS(): string;
procedure SetFieldS(const aValue: string);
public
property FieldS: string read GetFieldS write SetFieldS;
end;

I define binding:
LBinding := BindingGroup1.AddBinding(edtOne, 'Text', SomeObject, 'FieldS');
LBinding.BindingMode := bmTwoWay;
LBinding.TriggerMode := tmTwoWay;
LBinding.NotifyOnSourceUpdated := True;
LBinding.NotifyOnTargetUpdated := True;

When I change edtOne.Text then SomeObject.FieldS is updated, but when I change SomeObject.FieldS nothing happens in edtOne.Text. Why? How define "two way" updates?

Comments

  1. BindingMode is the way data is being transferred by the Binding. TriggerMode is to enable to let data flow back to the one that triggered it (granted that BindingMode allows that).

    Example: I change something in a control, BindingMode is twoway the setter of the object bound to that control changes something on the value (like not allowing certain values). If TriggerMode is twoway the data is allowed to go back into the control. Otherwise not.

    You can try this out with Sample1: put an OnChange event on Edit2 and set its Text to some fixed value. Now type into Edit1. The binding will try to update the Edit2 and will fire the OnChange event where you set the Text and it will trigger the binding again. If you have set the TriggerMode to twoWay the first Edit where you typed gets the value set.

    ReplyDelete
  2. Stefan Glienke Thx for clarification. And I have a question. Example ...\DSharp\Samples\MVVM\Calculator does not compile. Whether this "philosophy", described 5 years ago: http://delphisorcery.blogspot.com/2011/12/putting-pieces-together-dsharp.html) is still valid?

    ReplyDelete

Post a Comment