| 12345678910111213141516171819202122232425262728293031323334353637383940414243 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Globalization;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows.Data;
 
- namespace CyberX8_Themes.Converters
 
- {
 
-     public class DecimalPrecisionConverter : IValueConverter
 
-     {
 
-         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 
-         {
 
-             if (value is double number && parameter is int precision)
 
-             {
 
-                 return number.ToString($"F{precision}");
 
-             }
 
-             return value;
 
-         }
 
-         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 
-         {
 
-             if(value==null||parameter==null)
 
-             {
 
-                 return Binding.DoNothing;
 
-             }
 
-             if (value is double number)
 
-             {
 
-                 if (int.TryParse(parameter.ToString(), out int precision))
 
-                 {
 
-                     return Math.Round(number, precision);
 
-                 }
 
-                 else
 
-                 {
 
-                     return Binding.DoNothing;
 
-                 }
 
-             }
 
-             return Binding.DoNothing;
 
-         }
 
-     }
 
- }
 
 
  |