IsReadOnly property of WhiteTextBoxPeer

Jun 13, 2011 at 8:38 PM

I was checking IsReadOnly of a text box and even though it's in readonly mode (according to Snoop and my eyes!), White returned the value of IsReadOnly false. I looked at the source code of WhiteTextBoxPeer and noticed this code:

        public virtual bool IsReadOnly
        {
            get { return whitePeer.IsReadOnly; }
        }

Then I looked at WhitePeer class to see how IsReadOnly evaluated and I saw this:

        public virtual bool IsReadOnly
        {
            get { return false; }
        }

This is a bug, right?? I wonder if anyone ever had this problem? I wonder if this has anything to do with discussion: http://white.codeplex.com/discussions/53957

Jun 13, 2011 at 9:12 PM

I had to do this change in WhiteTextBoxPeer to fix the issue. By the way, I'm using WhiteTextBoxPeer in my OnCreateAutomationPeer of my AUT to use cosutom commands.

public virtual bool IsReadOnly
{
    get { return ((TextBox)Owner).IsReadOnly; }
}

Any comments?

Coordinator
Jun 14, 2011 at 5:59 AM

Yes you can say it is a bug, although strictly when using CustomControls (and custom commands) all information should be retrieved by writing custom commands. So in this case you should write a custom command to fetch the information about whether a textbox is readonly or not. The fact that IValueProvider interface has IsReadOnly method is an extra (not needed for custom commands framework). The CustomControls were created to support only custom commnands