Skip to content

Instantly share code, notes, and snippets.

@butaji
Created May 16, 2012 14:24
Show Gist options
  • Save butaji/2710736 to your computer and use it in GitHub Desktop.
Save butaji/2710736 to your computer and use it in GitHub Desktop.
Typed converter
public abstract class TypedConverter<TFrom, TTo> : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is TFrom)
return Convert((TFrom)value);
return Convert(default(TFrom));
}
public abstract TTo Convert(TFrom value);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment