Hi,
I have a very simple set of bindings in an iOS Controller, and I can't figure out why some are working and some aren't.
in my viewmodel, I have the following properties:
```
public BankAccountDetailsDto AccountDetails
{
get { return _accountDetails; }
set
{
if (Set(() => AccountDetails, ref _accountDetails, value))
{
RaisePropertyChanged(() => FormattedOperation);
UpdateCommands();
}
}
}
public Decimal Amount
{
get { return _amount; }
set
{
if (Set(() => Amount, ref _amount, value))
{
RaisePropertyChanged(() => IsRequestOk);
RaisePropertyChanged(() => FormattedOperation);
UpdateCommands();
}
}
}
public string FormattedOperation
{
get
{
return AccountDetails == null
? String.Empty
: String.Format(OperationFormat, AccountDetails.Balance, Amount, (AccountDetails.Balance + Amount));
}
}
```
In my Controller, I have the following bindings:
```
private void CreateBindings()
{
_bindings = new List<Binding>()
{
this.SetBinding(() => VM.FormattedOperation, () => this.Operation.Text, BindingMode.OneWay),
this.SetBinding(() => VM.AccountDetails.ChildName, () => this.ChildName.Text, BindingMode.OneWay)
.ConvertSourceToTarget(c => (c ?? String.Empty).ToUpper())
};
}
```
I'm aware of the problem with the iOS GC being too aggressive, so I store my bindings in a list.
My problem is that the 2nd binding is working perfectly as expected, the "ChildName" UILabel is always updated, but the "Operation" UILabel Text is set initially and never updated again.
While debugging my viewmodel, I find that the AccountDetails property is set, which triggers the
```
RaisePropertyChanged(() => FormattedOperation);
```
but the getter of "FormattedOperation" is never called afterwards, the UILabel Text never updated, etc.
By debugging through you code, I found out that in the "PropertyChangedEventManager", the method:
```
private void PropertyChanged(object sender, PropertyChangedEventArgs args)
{
if (!_list.ContainsKey(args.PropertyName))
{
return;
}
var list = _list[args.PropertyName];
if (list != null)
{
var recipients =
list.Where(
i => i.InstanceReference != null
&& i.InstanceReference.IsAlive
&& i.InstanceReference.Target == sender
&& i.Listener != null)
.ToList();
// We have the listeners. Deal with them
foreach (var item in recipients)
{
item.Listener.ReceiveWeakEvent(GetType(), sender, args);
}
}
}
```
is called with args.PropertyName = "AccountDetails", but never with args.PropertyName = "FormattedOperation", even just after the breakpoint in my vm on the line:
```
RaisePropertyChanged(() => FormattedOperation);
```
Any insight? am I doing something wrong?
The big mystery is that other bindings are working!
Comments: Hi, thanks for your answer. I used that workaround already, I have an IObservable<string> stream of propertyChanged events on my vm which allows me to do that, the only thing is that it's a bit unelegant to have 2 different ways of handling bindings in Controllers, the code looks a bit messy. About the problem, I have the feeling that the problems arises when u have bindings at different levels in the same Controller -> ``` this.SetBinding(() => VM.FormattedOperation, () => this.Operation.Text, BindingMode.OneWay); this.SetBinding(() => VM.AccountDetails.ChildName, () => this.ChildName.Text, BindingMode.OneWay); ``` The first one is at the root of the vm while the 2nd one is under an object at the root of the vm. I found out that I have actually other bindings at the root of the vm not working, while the bindings to properties inside of this BankAccountDetailsDto object are working fine. The other working bindings across my project are all in a situation where all the bindings for a given Controller are on properties on VM root, or all under a complex object held by a vm property. Hope this will help, Best regards, Remi.
I have a very simple set of bindings in an iOS Controller, and I can't figure out why some are working and some aren't.
in my viewmodel, I have the following properties:
```
public BankAccountDetailsDto AccountDetails
{
get { return _accountDetails; }
set
{
if (Set(() => AccountDetails, ref _accountDetails, value))
{
RaisePropertyChanged(() => FormattedOperation);
UpdateCommands();
}
}
}
public Decimal Amount
{
get { return _amount; }
set
{
if (Set(() => Amount, ref _amount, value))
{
RaisePropertyChanged(() => IsRequestOk);
RaisePropertyChanged(() => FormattedOperation);
UpdateCommands();
}
}
}
public string FormattedOperation
{
get
{
return AccountDetails == null
? String.Empty
: String.Format(OperationFormat, AccountDetails.Balance, Amount, (AccountDetails.Balance + Amount));
}
}
```
In my Controller, I have the following bindings:
```
private void CreateBindings()
{
_bindings = new List<Binding>()
{
this.SetBinding(() => VM.FormattedOperation, () => this.Operation.Text, BindingMode.OneWay),
this.SetBinding(() => VM.AccountDetails.ChildName, () => this.ChildName.Text, BindingMode.OneWay)
.ConvertSourceToTarget(c => (c ?? String.Empty).ToUpper())
};
}
```
I'm aware of the problem with the iOS GC being too aggressive, so I store my bindings in a list.
My problem is that the 2nd binding is working perfectly as expected, the "ChildName" UILabel is always updated, but the "Operation" UILabel Text is set initially and never updated again.
While debugging my viewmodel, I find that the AccountDetails property is set, which triggers the
```
RaisePropertyChanged(() => FormattedOperation);
```
but the getter of "FormattedOperation" is never called afterwards, the UILabel Text never updated, etc.
By debugging through you code, I found out that in the "PropertyChangedEventManager", the method:
```
private void PropertyChanged(object sender, PropertyChangedEventArgs args)
{
if (!_list.ContainsKey(args.PropertyName))
{
return;
}
var list = _list[args.PropertyName];
if (list != null)
{
var recipients =
list.Where(
i => i.InstanceReference != null
&& i.InstanceReference.IsAlive
&& i.InstanceReference.Target == sender
&& i.Listener != null)
.ToList();
// We have the listeners. Deal with them
foreach (var item in recipients)
{
item.Listener.ReceiveWeakEvent(GetType(), sender, args);
}
}
}
```
is called with args.PropertyName = "AccountDetails", but never with args.PropertyName = "FormattedOperation", even just after the breakpoint in my vm on the line:
```
RaisePropertyChanged(() => FormattedOperation);
```
Any insight? am I doing something wrong?
The big mystery is that other bindings are working!
Comments: Hi, thanks for your answer. I used that workaround already, I have an IObservable<string> stream of propertyChanged events on my vm which allows me to do that, the only thing is that it's a bit unelegant to have 2 different ways of handling bindings in Controllers, the code looks a bit messy. About the problem, I have the feeling that the problems arises when u have bindings at different levels in the same Controller -> ``` this.SetBinding(() => VM.FormattedOperation, () => this.Operation.Text, BindingMode.OneWay); this.SetBinding(() => VM.AccountDetails.ChildName, () => this.ChildName.Text, BindingMode.OneWay); ``` The first one is at the root of the vm while the 2nd one is under an object at the root of the vm. I found out that I have actually other bindings at the root of the vm not working, while the bindings to properties inside of this BankAccountDetailsDto object are working fine. The other working bindings across my project are all in a situation where all the bindings for a given Controller are on properties on VM root, or all under a complex object held by a vm property. Hope this will help, Best regards, Remi.