In my case, I have a TextBox and two buttons Button1 and Button2. Here is how I am doing..
private void Button1_click()
{
TextBox.IsReadOnly = false;
}
private void Button2_click()
{
TextBox.IsReadOnly = true;
this.Focus()
}
Now the flow, what I am doing…
- Program loads, I click on the TextBox, the SIP appears and I click somewhere on the screen the keyboard disappears.
- I press Button2 and the TextBox becomes read only and the SIP disappears (if it was shown)
- I tap on the TextBox (while it is still in the read only mode)
- I press Button1, and click on the TextBox.. BOOOMM.. the program crashes with an UnHandledException.
…
I have tried gotfocus() and LostFocus of TextBox but nothing seems to help, Just before crashing, the GotFocus of the TextBox is NOT called. I tap on the textBox and suddenly it crashes.
Really trying to figure out what could be wring for the last 9 hours (oh yeah, I am dumb programmer 🙂
Could anyone please put some light on the problem and tell me any possible solution?
Thanks very much 🙂
After working really hard on this issue, I finally used two separate textBoxes and set the visibility true/false on the button clicks.
I removed all the events of the TextBox, I simplified the code (properties values and events) to as much extent as possible but the code was crashing.
One thing I noticed though,
As in the 4th point in my questions, I clicked on the Button1, then on the textBox and it was crashing. But when I did it like “press Button1, click anywhere on the screen, and then clicking the TextBox didn’t crash)
Strange!