MonoMobile.Views.BindingExpression.ConvertValue C# (CSharp) Method

ConvertValue() public method

public ConvertValue ( object value ) : object
value object
return object
        public object ConvertValue(object value)
        {
            object convertedValue = value;

            var memberType = TargetProperty.GetMemberType();

            if (Binding.Converter != null)
            {
            //				try
                {
                    object parameter = Element;
                    if (Binding.ConverterParameter != null)
                        parameter = Binding.ConverterParameter;

                    convertedValue = Binding.Converter.Convert(value, memberType, parameter, CultureInfo.CurrentUICulture);
                }
            //				catch (InvalidCastException) {}
            //				catch (NotSupportedException) {}
            //				catch (NotImplementedException) {}
            }

            var typeCode = Convert.GetTypeCode(convertedValue);
            if (typeCode != TypeCode.Object && typeCode != TypeCode.Empty)
            {
                convertedValue = Convert.ChangeType(convertedValue, memberType);
            }

            return convertedValue;
        }

Usage Example

示例#1
0
        public object Convert()
        {
            object sourceValue = ControlValue;

            sourceValue = BindingExpression.ConvertValue(sourceValue);
            return(sourceValue);
        }
All Usage Examples Of MonoMobile.Views.BindingExpression::ConvertValue