I get major visual glitching with the following textbox configuration. When the text in the textbox passes one line width, the text scrolls to the left out of view, among other things. Control+A to select all will generally redraw stuff correctly. This happens
with both KeyDown and KeyUp events and happens even if I set e.Handled to false.
Sander Saares
Member
12 Points
13 Posts
Wrapped textbox + keyboard event handler = broken textbox
Oct 27, 2008 12:37 PM | LINK
I get major visual glitching with the following textbox configuration. When the text in the textbox passes one line width, the text scrolls to the left out of view, among other things. Control+A to select all will generally redraw stuff correctly. This happens with both KeyDown and KeyUp events and happens even if I set e.Handled to false.
The defect occurs when typing into the textbox.
I've tested on FF3 and IE7 on Vista.
<
TextBox TextWrapping="Wrap" Width="300" Height="300" KeyDown="TextBox_KeyDown" />private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
e.Handled = false; // No matter whether I set this to false or true.
}
textbox keyboard keydown keyup event
StefanWick
Contributor
3004 Points
453 Posts
Microsoft
Re: Wrapped textbox + keyboard event handler = broken textbox
Oct 27, 2008 02:47 PM | LINK
Can you do this quick test to narrow this down?
If you subscribe to the KeyDown event handler in code (as oppossed to subscribing in XAML), does that change the behavior?
Thanks, Stefan Wick
Sander Saares
Member
12 Points
13 Posts
Re: Re: Wrapped textbox + keyboard event handler = broken textbox
Oct 28, 2008 05:04 AM | LINK
Yes, the defect does not occur if I attach the event handler in code.
StefanWick
Contributor
3004 Points
453 Posts
Microsoft
Re: Re: Wrapped textbox + keyboard event handler = broken textbox
Oct 28, 2008 05:15 AM | LINK
OK, thanks for confirming. You are hitting a known bug with this scenario. The workaround is to attach the event handler in code.
Thanks, Stefan Wick
Microsoft Silverlight