Search code examples
c#dependencyobject

Cannot convert type 'int' to 'bool'


I'm working on a custom login Textbox that has an Auto Complete function. However, When i try to:

public static void SetSelectOnMouseOver(DependencyObject obj, bool value)
    {
        obj.SetValue(ListBoxItemBehavior.SelectOnMouseOverProperty, 
            (object)(bool)(value ? 1 : 0));
    }

I get an error (object)(bool)(value ? 1 : 0)); > cannot convert type 'int' to 'bool', what's wrong?


Solution

  • value is already a bool. Why not just use (object) value, or even just value?