Simple Bindable Divison Converter C#
This snippet is a plug and play division converter written in c#. You can bind the converter to any suitable WPF XAML Control. Further, just by changing the operator you can apply this converter to other operations like, adding, muliply, substract, shift etc. Enjoy :-)
public class DivisionConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { double result = 1.0; for (int i = 0; i < values.Length; i++) { if (values[i] is double) { if(((double)values[i])==0.0) result /= (double)values[i]; } } return result; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new Exception("Method is not implemented"); } }
Post a Comment
0 Comments
Thanks!