using System;
using System.Globalization;
using System.Windows.Data;
using Telerik.Windows.Controls;

namespace CellTemplateProblem
{
    class ItemConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {           
            if (value == null) return null;

            var row = (RowItem) value;
            var column = (GridViewDataColumn) parameter;

            return row.GetItemForColumn((int) column.Tag);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {            
            //Maybe you need to write some additional ConvertBack logic here.
            return value;
        }
    }
}
