Thursday, March 08, 2012

TwoWay binding issue while using ApplicationBar Icon

Just after my encounter with ApplicationBar Icons and RelayCommands, I faced another issue with two-way binding of a textbox. I had 3 textboxes in the page and 2 of them where binding properly. One of them was misbehaving. It was not misspelt (I checked that many times - I even rewrote the property and the binding element.) for sure. What could that be? After hours of head-scratching, I ventured into bing hunting! Google with Bing, as Scott Hansleman puts it.

It seems it is a problem with ApplicationBar button. No, not again!

OK, I have to be ready for it, it seems, as any elements in the ApplicatioBar is not a proper element. So don't expect a normal behavior. :)

So, the story is that binding would not work on the textbox on which the focus is on when pressing the button in the Application Bar. So, we have to manually (programmatically, I mean) bind it. Code Behind? Yes.

Laurent has a workaround in this article. It works (of course!), but it needs the textbox to be named. I found some other workaround while googling with bing.

And guess what, everything works like a charm. As they say, all's well that ends well! :)

No comments:

Post a Comment