public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Checks if the value provided is null, if so then tell the converter that the value is unset
if (value == null || !(value is Enum))
return DependencyProperty.UnsetValue;
// Gets the parameter and check if it is null, if so then tells the converter, that the value is unset
string enumValueName = parameter as string;
if (enumValueName == null)
return DependencyProperty.UnsetValue;
// Checks if the enum type, from which is to be converted defines the value that is to be converted to boolean, if not, then tell the converter, that the value is unset
if (!Enum.IsDefined(value.GetType(), value))
return DependencyProperty.UnsetValue;
// Converts the parameter value to the enum type
object parameterEnumValue = Enum.Parse(value.GetType(), enumValueName);
// If the parameter equals the value that is to be converted, then returns true, otherwise false is returned
return parameterEnumValue.Equals(value);
}