I have a lot (about 30) TextBoxes in the same window and I want to register all of them to the same PreviewKeyDown Event. Is there any easy way of signing all of them without the need to sign each of the textBoxes (in the XAML code) individualy?
Thanks in advance,
Gil.

brunda kRank #3,804 · 389 reputationPosted Jun 13, 2012, 4:33 AM EDT
http://www.koders.com/csharp/fidA8BD3088D2F2C65644CA511813DC5153C91C52A2.aspx?s=file
VulpesRank #55 · 29.2K reputationPosted Jun 13, 2012, 12:41 AM EDT
If you select the first TextBox, find its PreviewKeyDown event in the Properties Box and double click it, this will create your skeleton handler.
If you then find the PreviewKeyDown events for the other TextBoxes in the Properties Box, you'll see that there's a drop down box from which you can select the handler that you've created thereby wiring up all the TextBoxes to the same handler.
brunda kRank #3,804 · 389 reputationPosted Jun 13, 2012, 12:55 AM EDT
EventManager.RegisterClassHandler(typeof(TextBox),
TextBox.PreviewKeyDown,
new System.Windows.Input.KeyEventHandler(TextBox_PreviewKeyDown));
gil elgrably12 reputationPosted Jun 13, 2012, 3:05 AM EDT
Well thanks, but were do I put this code?
I'm receiving this (static) error:
"RegisterClassHandler is a Method but used like a type"gil elgrably12 reputationPosted Jun 13, 2012, 10:23 AM EDT