Sorry about that. Here is the class for DecimalIntConverter public class DecimalIntConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { return Decimal.ToInt32((Decimal)value); } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } }
Good idea! It would be better to check the type before converting it. In this case the property that is being Binded is already type Decimal so i did not think to check before converting as this is only any tutorial. But it is a very good idea to check the type.
Hello. Thank you for your videos. I want to ask you. How you did the DecimalIntConverter?
Sorry about that. Here is the class for DecimalIntConverter
public class DecimalIntConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return Decimal.ToInt32((Decimal)value);
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Is it better to check if it's really a decimal value? I mean something like this:
if (value is decimal)
return System.Convert.ToInt32(value);
Good idea! It would be better to check the type before converting it. In this case the property that is being Binded is already type Decimal so i did not think to check before converting as this is only any tutorial. But it is a very good idea to check the type.
Can I email you or something? I want to ask you something. If you want (and can) send me a message in my youtube account.
Sorry about the delay. You can email me at RabbitApps@outlook.com