Hi,
I have a main grid and in that grid there are many components, I want to keep the focus on one component all the time, even use make a mouse lick on other component, at mouseleftbuttonup, i am trying to set the focus back to my default place, i.e.
mystargrid.Focus()
it do not change the focus once user make a mouse click on other components, any idea to force the focus back to my desired place after use mouse click ?
Regards
Answer: 1
Hi joji777,
joji777
it do not change the focus once user make a mouse click on other components, any idea to force the focus back to my desired place after use mouse click ?
You should add a handler for MouseLeftButtonUp event. Please try:
public MainPage() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainPage_Loaded); button1.AddHandler(Button.MouseLeftButtonUpEvent, new MouseButtonEventHandler(button1_MouseLeftButtonUp), true); } void MainPage_Loaded(object sender, RoutedEventArgs e) { System.Windows.Browser.HtmlPage.Plugin.Focus(); textBox1.Focus(); } private void button1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { // Dispatcher.BeginInvoke(() => { textBox1.Focus(); }); textBox1.Focus(); }
UIElement.AddHandler Method
http://msdn.microsoft.com/en-us/library/ms598899(v=vs.95).aspx?ppud=4
Best Regards,
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog