How to Use Crosslight v2 IValueConverter in BindingProvider Objects?

2 replies. Last post: August 27, 2014 12:46 AM by Hans Kristian
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hi,


We have a code snippet below, but this isn't working for BindingProviders. Well, not for null values anyway. See, that's the thing... what if you want to convert a null value into something else? Why is IValueConverter.Convert not being triggered if the value bound to a property is null? If we're missing something, please let us know.

var p_ActualCash = new BindingDescription("Item.ActualCash") { StringFormat = "{0:c2}", Converter = new NullValueConverter() };
var p_ActualToken = new BindingDescription("Item.ActualToken") { StringFormat = "{0:n0}", Converter = new NullValueConverter() };

this.AddBinding("ActualCashLabel", BindableProperties.TextProperty, p_ActualCash);
this.AddBinding("ActualTokeLabel", BindableProperties.TextProperty, p_ActualToken);


The goal of this is to display zero instead of empty string when the value bound to a Text property is null. And the StringFormat should be able to format the zero value. We could use TextField controls and assign placeholder values but that's just a weak solution, especially since currency symbols depend on mobile's culture info. Please advise.

All times are GMT -5. The time now is 4:32 PM.
Previous Next