locked
System.Windows.Controls.TextBox "HideSelection" equivalent work-around RRS feed

  • Question

  • I was wondering if anyone knows of a way to get the "HideSelection" feature in System.Windows.Forms.TextBox class for the System.Windows.Controls.TextBox class.

    I am trying to create a find/replace dialog which is high-lighting the text it finds (if any), but you can't see it until the text box re-gains the keyboard focus (a major problem!).

    There are also some features in the System.Windows.Controls.TextBox class that aren't in the Forms equivalent (and I would really not want to re-implement these myself).

    Tuesday, May 25, 2010 8:50 PM

Answers

  • Hi helloworld,

     

    The Winform TextBox’s HideSelection property is not supported in WPF. However, there is an easy way to keep highlight color when WPF textbox lose focus. You can handle the LostFocus event of WPF Textbox to set e.Handled to true. The focus of the TextBox does lost but the selection color remains.

     

    Hope it helps.

     

    Sincerely,

    Kira Qian
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by Kira Qian Tuesday, June 1, 2010 3:08 AM
    Thursday, May 27, 2010 8:49 AM

All replies

  • Hi helloworld,

     

    The Winform TextBox’s HideSelection property is not supported in WPF. However, there is an easy way to keep highlight color when WPF textbox lose focus. You can handle the LostFocus event of WPF Textbox to set e.Handled to true. The focus of the TextBox does lost but the selection color remains.

     

    Hope it helps.

     

    Sincerely,

    Kira Qian
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by Kira Qian Tuesday, June 1, 2010 3:08 AM
    Thursday, May 27, 2010 8:49 AM
  • Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Tuesday, June 1, 2010 3:08 AM