Ejemplo n.º 1
0
        /// <inheritdoc/>
        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var collection = parameter as IList;

            if (collection == null)
            {
                return(null);
            }

            var index = ConverterHelper.ConvertToInt32(value ?? -1, culture);

            if (index < 0 || index >= collection.Count)
            {
                return(null);
            }

            return(collection[index]);
        }
Ejemplo n.º 2
0
 /// <inheritdoc/>
 public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(targetType == typeof(int) ? ConverterHelper.ConvertToInt32(value, culture) : ConverterHelper.TryConvertToInt32(value, culture));
 }