locked
Set focus to a textblock?? RRS feed

  • Question

  • Hi,

    For some reason when I try this with a textblock it returns false :-(. It works fine with a textbox.

    var temp = myTextBlock.Focus(FocusState.Programmatic); // returns false

    why is a textblock not focusable?

    thnx

    Brian

    Friday, January 30, 2015 2:18 PM

Answers

  • Then you cannot set the focus to a TextBlock. You can set the focus only to a Control which is in the tab order (I had misremembered the TextBlock as being a Control, but it is not. It is a FrameworkElement).

    • Marked as answer by duffybr Friday, February 6, 2015 2:55 AM
    Friday, February 6, 2015 2:45 AM
    Moderator

All replies

  • Text blocks are not in the tab order by default. If you want to place it in the tab order set its IsTabStop property.
    • Proposed as answer by Jamles HezModerator Friday, February 6, 2015 1:56 AM
    • Unproposed as answer by duffybr Friday, February 6, 2015 2:06 AM
    Friday, January 30, 2015 2:34 PM
    Moderator
  • It looks like TextBlock does not support isTabStop property :-(
    Friday, January 30, 2015 3:25 PM
  • That property is not available on a TextBlock only on a TextBox
    Friday, February 6, 2015 2:05 AM
  • Then you cannot set the focus to a TextBlock. You can set the focus only to a Control which is in the tab order (I had misremembered the TextBlock as being a Control, but it is not. It is a FrameworkElement).

    • Marked as answer by duffybr Friday, February 6, 2015 2:55 AM
    Friday, February 6, 2015 2:45 AM
    Moderator