Forum Xamarin.Forms

How to pass ConverterParameter to a binding, when using SetBinding in code.

BoVisfeldtBoVisfeldt DKMember ✭✭
edited August 2015 in Xamarin.Forms

When using ValueConverters in bindings, you can pass arguments to them from the binding like this using XAML:

(Excerpt from Xamarin tutorial)
<Label Text="{Binding Color.R, Converter={StaticResource intConverter}, ConverterParameter=255, StringFormat='R={0:X2}'}" />

I do, however, need to set a binding from code like this from code behind:
template.SetBinding(HeaderCell.ExpiresProperty, vm => vm.ExpiryDate, BindingMode.OneWay, dateTimeValueConverter);

In doing so, I am uncertain as how to pass the ConverterParameter.
Naturally, I could use properties to modify the behavior of the converter - but I would prefer to figure out how to do it properly.

Best Answer


  • BoVisfeldtBoVisfeldt DKMember ✭✭

    Thanks :)

  • LoriLalondeLoriLalonde CAInsider, University, Developer Group Leader ✭✭✭

    You're welcome! I'm always happy to help :)

Sign In or Register to comment.