I have a converter that allow me to convert between SelectedItems and a Generic List<MyType>
public class SelectedTiposDocsToList : BaseConverter, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var Selecteditems = value as IList;
List<MyType> MyTypeList = Selecteditems.Cast<MyType>().ToList();
return MyTypeList;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Now this is a common task for me and want to extend this class to allow a generic type is this something like this maybe ?
public class SelectedTiposDocsToList : BaseConverter, IValueConverter
{
public object Convert<T>(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var Selecteditems = value as IList;
List<T> MyTypeList = Selecteditems.Cast<T>().ToList();
return MyTypeList;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Is this Possible ? If Yes.. How to use thsi type of converter on XAML ?