public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (Expression == null) return value; if (parser == null) { parser = new LambdaParser(Expression, true); //set a default parser.Params = new LambdaParameter[] { new LambdaParameter { ParamType = targetType, ParamName = "param" } }; //parse the expression func = parser.ParseExpression().Compile(); } //if the user wants to use the value as a string we need to change the object type if (targetType == typeof(string)) value = value.ToString(); return func.DynamicInvoke(value); }