feedburner
Enter your email address:

Delivered by FeedBurner

feedburner count

WP7 Dev - Problems with TextBox SelectionChanged event

Etiketter: , ,

As I was coding on my app for Windows Phone 7 I ran in to an issue and found no reference to it on the web, so I thought I would post about it.

I was making a test page to show what's in the Isolated Storage, to verify that my writes was working as they should. When writing this test page I used a textbox and wrote some results too. I wanted to use the SelectionChanged event to catch the selection but I could not get it to work.

After scouring the web I couldn't find any one with similar issues except people posting about a bug that was firing off two events instead of one for the SelectionChanged event. I could debug and see that the event really fired. But I could not get it to return any value other than an empty string.
The code used was a simple:

private void textBox2_SelectionChanged(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox2.SelectedText;
}
The screenshot below shows the selection but lack of resut in the upper texbox.


Since I only wanted to select items from this textbox I had set the property IsReadOnly to true. And it seems there is a bug in the beta tools, because when setting this property to false the event returns the proper value. So, using a textbox which is editable will enable you to receive the proper value. The screenshot below shows the event having returned the proper value after the textbox control has been marked as editable.


Now I know this isn't proper usage of a textbox, showing static texts and making them selectable should be handled by a listbox, but some one still might try this out so the information could be pertinent.



1 kommentarer:
gravatar
Anonymous said...
June 1, 2011 at 6:34 AM  

did you end up figuring this out? it seems like even the RTM tools have this bug :(

Post a Comment