Unanswered A way to watch tab focus events?

  • Friday, November 16, 2012 7:29 PM
     
     
    I work large Silverlight project with a lot of MVVM & Caliburn Micro. I've got an issue on tab order where some unseen objects are receiving tab focus I can't identify. Is there something for Silverlight that can allow me to watch / identify objects as they receive tab focus so to help figure out what's actually receiving these tab stops that I'm not seeing? Would very much like to know if there is, thanks!




    Please mark answers as helpful when used, and answered when completed.

All Replies

  • Friday, November 16, 2012 8:05 PM
     
      Has Code

    You can use FocusManager...

    Something like this would tell you the item type and name if you gave it one that has the focus...

    private void UserControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    		{
    			if (e.Key == Key.Up)
    			{
    				var obj = FocusManager.GetFocusedElement();
    				FrameworkElement d = obj as FrameworkElement;
    				MessageBox.Show(obj.GetType().Name + " - " + d.Name.ToString());
    			}				
    		}

    I stuck the keyDown event on the main UserControl.

    ~Christine


    My Gallery

  • Monday, November 19, 2012 5:30 PM
     
     
    Ah that is clever Christine! I'm going to have to give it a shot but I'm thinking Caliburn's ViewBinder might break the focus tracking from the viewmodel bindings which is what I ran into last time I tried something similar with focusmanager, Caliburn definitely has its pros, but sometimes the cons are just as much of a pain in the butt haha.




    Please mark answers as helpful when used, and answered when completed.