"mvvmcross binding with format string" Code Answer

3

to do this, you can just create a stringformatvalueconverter and you can use it's parameter as the format string to use.

should take about 2 minutes to write... here, i'll prove it:

public class stringformatvalueconverter : mvxvalueconverter
{
    public override object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture)
    {
        if (value == null)
            return null;

        if (parameter == null)
            return value;

        var format = "{0:" + parameter.tostring()  + "}";

        return string.format(format, value);
    }
}

then

set.bind(mylabel).to(vm => vm.thedate).withconversion("stringformat", "hh:mm:ss");

1 minute 53 seconds ;)

By eddies on August 3 2022

Answers related to “mvvmcross binding with format string”

Only authorized users can answer the Search term. Please sign in first, or register a free account.