未调用mvvmcrosscore valueconverters

时间:2013-11-07 07:24:47

标签: mvvmcross

我写了这两个转换器,但它们没有被“调用”......我是否需要在minisetup.cs文件中添加额外的代码才能使它们正常工作

public class BooleanNegationValueConverter : IMvxValueConverter
    {
        #region IMvxValueConverter implementation

        public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (!(Boolean)(value));
        }

        public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException ();
        }

        #endregion

我以通常的方式使用它

set.Bind(toolbar.hidden).To(vm => vm.toolbarstate).WithConversion("BooleanNegation");

我正在使用MvvmcrossCore

1 个答案:

答案 0 :(得分:0)

自己弄清楚..

//Register the converters
        IMvxValueConverterRegistry converterRegistery = ioc.Resolve<IMvxValueConverterRegistry>();
        converterRegistery.AddOrOverwrite ("BooleanNegationConverter", new BooleanNegationValueConverter ());
        converterRegistery.AddOrOverwrite ("ExchangeRatetoStringValueConverter", new ExchangeRatetoStringValueConverter ());