Skip to content Skip to sidebar Skip to footer

System.formatexception In Mvvmcross

The following code updates properties on-the-fly via mvvmcross messaging protocol. The problem that I am facing now, when user clears either age or category textviews, then I am g

Solution 1:

You need a value converter which converts empty string to null and you need to make Age property nullable. After that you will need to specify the converted in the binding:

publicclassNullableValueConverter : MvxValueConverter
{
    publicoverrideobject Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return value;
    }

    publicoverrideobject ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value == null || string.IsNullOrEmpty(value.ToString()))
        {
            returnnull;
        }

        return value;
    }
}

and inside your view:

local:MvxBind="Text Age,Converter=Nullable;"

You can read more about value converters at Value Converters Wiki

Post a Comment for "System.formatexception In Mvvmcross"