"is it possible to create a generic int-to-enum converter?" Code Answer

3

i think i figured it out

i just needed to set my converterparameter instead of the value equal to the enum i am looking for, and evaluate for true/false

<datatrigger value="true"
             binding="{binding someintvalue, 
                 converter={staticresource isintequalenumconverter},
                 converterparameter={x:static local:myenum.somevalue}}">

converter

public object convert(object value, type targettype, object parameter, cultureinfo culture)
{
    if (parameter == null || value == null) return false;

    if (parameter.gettype().isenum && value is int)
    {
        return (int)parameter == (int)value;
    } 
    return false;
}
By Sanjit Saluja on June 15 2022

Answers related to “is it possible to create a generic int-to-enum converter?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.