using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace CyberX8_MainPages.Converters { public class AllNoneCheckboxConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool result = (bool)values[0]; for (int i = 0; i < values.Length; i++) if (result != (bool)values[i]) return null; return result; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { object[] result = new object[targetTypes.Length]; bool isChecked = (bool)value; for (int i = 0; i < result.Length; i++) if (isChecked) result[i] = true; else result[i] = false; return result; } } }