Exemple #1
0
        // Value is a string, we need to create a native object.
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            System.Diagnostics.Debug.WriteLine("Calling ConvertBack from PropDirectConverter.");

            DirectConverterParameter dcp = (DirectConverterParameter)parameter;
            TwoTypes tt = dcp.GetTwoTypes();

            if (value == null)
            {
                return(Binding.DoNothing);
            }

            try
            {
                object pValue = ((IPropBagMin)value).GetValWithType(dcp.PropertyName, dcp.SourceType);
                object result = ValueConverter.ConvertBack(pValue, targetType, tt, culture);

                // Set the value, here, since this converter expects an entire IPropBagMin.
                ((IPropBagMin)value).SetValWithType(dcp.PropertyName, dcp.SourceType, pValue);
            }
            catch
            {
                // Suppress all errors.
            }
            return(Binding.DoNothing);
        }
Exemple #2
0
        // Value is native object, we need to return a targetType (hopefully a string at this point.)
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            System.Diagnostics.Debug.WriteLine("Calling Convert from PropDirectConverter.");

            DirectConverterParameter dcp = (DirectConverterParameter)parameter;
            TwoTypes tt = dcp.GetTwoTypes();

            object pValue = ((IPropBagMin)value).GetValWithType(dcp.PropertyName, dcp.SourceType);

            try
            {
                object result = ValueConverter.Convert(pValue, targetType, tt, culture);
                return(result);
            }
            catch
            {
                return(Binding.DoNothing);
            }
        }