1

Closed

Bug in TextBinding

description

There is what I would consider a bug in the TextBinding attached property helper. Classes that derive from TextBox and PasswordBox should be able to take advantage of this attached property, but they cannot due to the current implementation. In my case, this causes a problem with the PhoneTextBox in the Windows Phone Toolkit.
 
The offending code is:
 
    private static void HandleUpdateSourceOnChangeEventAppend(object sender, bool value)
    {
        var type = sender.GetType();
 
        if (type == typeof(TextBox))
            HandleUpdateSourceOnChangeEventAppendTextBox(sender, value);
        else if (type == typeof(PasswordBox))
            HandleUpdateSourceOnChangeEventAppendPassword(sender, value);
    }
 
Changing the "type == typeof(TextBox)" statements to "sender is TextBox" and "sender is PasswordBox" would resolve this issue without any other side effects that I can see.
Closed Feb 2, 2012 at 4:49 AM by
Fixed with new test case in test app.
Completed: At revision: 72121

comments

crutkas wrote Jan 29, 2012 at 7:00 PM

Good bug. Didn't think about someone doing that.