I am currently setting a label binding from code behind which works fine as below:
lblLabel.SetBinding(Label.TextProperty, model.DataField);
However I now need to add multiple bindings (model.Title and model.DataField) to the Label so want to bind the entire BindingContext to use in a converter, in XAML I would use:
{Binding .}
So have tried the following from the code behind but this just passes null to the converter?
lblLabel.SetBinding(Label.TextProperty, ".", BindingMode.Default, new ModelToStringConverter());
Is this possible to achieve from the code behind or can you only use "." in XAML directly?
The equivalent to XAML's "."
is this
.
For your scenario, you need the path as a string tho, so you can use "."
by creating a new Binding
:
ModelToStringConverter modelToStringConverter = new ModelToStringConverter();
txtBlock.SetBinding(TextBlock.TextProperty, new Binding(".", converter: modelToStringConverter);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.