Quote:
Originally Posted by lifeguru02
we use dapfor wpf gridcontrol in our department to do assignments and lessons. Our lecturer told us today to differentiate between data formatting and templating.
|
C#
internal class IntToStringConverter : IValueConverter
{
#region IValueConverter Members
// Converts int-type value to string
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int)
{
return string.Format(culture, "{0}", value);
}
return null;
}
// Parses string to int-type value
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
string s = value as string;
if(!string.IsNullOrEmpty(s))
{
return int.Parse(s, culture);
}
return Binding.DoNothing;
}
#endregion
}