1 Reply Latest reply on Sep 13, 2007 4:32 PM by Senor_Roberto

    Flex equivalent to WPF IValueConverter?

      Hi all,

      In WPF, you can implement an interface named IValueConverter which has Convert() and ConvertBack() methods which convert a value from an object to a string and vice versa. JSF has something similar. I want to do in Flex what is done in the example in the following document.


      Namely, I want to bind a Date to a TextInput. However, I don't want to use the default toString() and parse() conversions. I want to be able to customize the format that the date is displayed in in the TextInput. Then, I want to be able to parse it back into a Date.

      I see that you can use BindingUtils to specify a setter function. However, I need a getter function too. Can I do this in Flex?

        • 1. Re: Flex equivalent to WPF IValueConverter?
          Senor_Roberto Level 1
          I have done a similar thing but I couldn't find anything in Flex which is the equivalent.

          I ended up building a decorator object with public getter/settor mutator method for a property called 'value'.
          I then bound object.value instead of just the property.

          In the case of a date:

          public class DateDecorator {

          private var _realdate:String; // or whatever

          public function set value (date:String) : void {
          // Convert to internal value

          public function get value () : String {
          // Convert to external value



          var dd:DateDecorator = new DateDecorator();

          And bind the value property, {dd.value}