EnumToBooleanConverter.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using Microsoft.UI.Xaml.Data; 7 8 namespace Microsoft.PowerToys.Settings.UI.Controls.Converters 9 { 10 public partial class EnumToBooleanConverter : IValueConverter 11 { 12 public object Convert(object value, Type targetType, object parameter, string language) 13 { 14 if (value == null || parameter == null) 15 { 16 return false; 17 } 18 19 // Get the enum value as string 20 var enumString = value.ToString(); 21 var parameterString = parameter.ToString(); 22 23 return enumString!.Equals(parameterString, StringComparison.OrdinalIgnoreCase); 24 } 25 26 public object ConvertBack(object value, Type targetType, object parameter, string language) 27 { 28 throw new NotImplementedException(); 29 } 30 } 31 }