My problem is when there is focus on a button and i click the spacebar, the buttonEvent gets triggered. This is a normal of course, although the problem is that I set focus to another control, and the button event STILL gets fired when i press the spacebar.
Here is the scenerio.
- I have several buttons and a textblock.
- All the buttons have a dynamically created event
b.Click += new RoutedEventHandler(OnButtonClick);
- No Matter where I add the following code, It does not set focus on the
TEXTBLOCK (do no confuse with textBOX).
tb.Focus(Windows.UI.Xaml.FocusState.Programmatic);
or
this.Focus(Windows.UI.Xaml.FocusState.Programmatic); // doesn't work either
So whenever I run an action (in this case Im reading each keystroke the user types in), I always set the focus on this.focus or tb.focus but as soon as i press SPACEBAR the (OnButtonClick) gets called.
Each key I press sets the focus back to the textblock & Each button i click sets the focus back to the textblock and still whenever i press the SPACEBAR the OnButtonClick gets called.
Also If a Click Button#3, the button event sets focus to the textblock. As soon as i type Spacebar it fires OnButtonClick of Button#3 the last button I clicked on screen.
Why? what am i doing wrong, what am i missing?