Selection Color of a TextBox RRS feed

  • Question

  • How do I change the selection color of a textbox. I tried to find the Rectangle, Border or what kind of control it is i Expression Blend but I can´t find it. I have a light blue backround in my application so having a selection collor that is also lightblue is not the best option.



    Tuesday, October 23, 2007 1:35 PM


  • currently this scenario is not supported. We are looking at this for future releases.


    Wednesday, October 24, 2007 12:24 AM

All replies


    As far as I know, it's not an option.  See this thread.
    Tuesday, October 23, 2007 3:11 PM
  • They are talking about a property that could set the color of the selection. That would bee nice to have. But I hope that you can change this color by modefying the controltemplates of the elements in the TextBox control. It´s just a matter of how far you would like to dig in the tree. It this true or is it totaly impossible to change the selection color? do I have to write my own TextBox control?




    Tuesday, October 23, 2007 7:18 PM
  • It is entirely impossible in the current .NET releases (3.0 & 3.5 beta).  The control is hardcoded to use the system setting... it doesn't look at the control template at all.


    Hopefully this feature will be added in the next release after 3.5.


    If you're willing to write your own TextBox control just to get this feature, then you must *really* want it!  Wink  If I were to make a list of native controls I'd *least* want to reinvent, TextBox would be toward the top of the list (and anything else dealing with text input would be very close behind).

    Tuesday, October 23, 2007 8:59 PM
  • currently this scenario is not supported. We are looking at this for future releases.


    Wednesday, October 24, 2007 12:24 AM
  • It´s not about what I want or not want. It´s abound what my designer want. He has chosen another color and that color it´s going to be in the textboxes in our application. God for me that Microsoft is releasing the source code for .Net so I can hardcode another value in the textbox control. I am not supposing to but what do you do? Isn´t the idea of WPF that the implementation and the appearance of a control are separated?

    Thanks for the answer thou.




    • Proposed as answer by melmar Saturday, September 12, 2009 1:26 AM
    Monday, October 29, 2007 12:43 PM
  • Don't do it. Just respect the user's settings. Just because your personal setting for the highlight color is light blue, and that doesn't happen to go with the background color you've chosen for your application, does not mean you should impose your preference onto your users.


    Monday, October 29, 2007 1:15 PM
  • I agree. But if your Art Director says green its going to be green and not light blue.

    I loved WinForms. It had the windows look. But now we have WPF and (almost) anything is possible.




    Monday, October 29, 2007 1:25 PM
  • I strongly disagree with the Tim Dawsons's view.

    Currently text box user settings are not respected. For instance I personally prefer the TextBox with violet background and white text

    because with standard white background my eyes start to hurt after several hours. But when I tried to set the Window color on my computer

    to violet and the foreground to white I noticed that many applications including Microsoft Access (2003) could not handle this. I often

    encountered white text on white backgound. So I had to switch back to the standard white background and black text. This clearly shows that

    user settings are not respected. With application themes it would be possible to assure that at least for the application I'm writing that

    the user can choose the settings he really likes.

    I did some research on this and found out that many people actually don't like the white background if they have to sit a long time before

    the computer. But most users don't even know that the color settings of the Window defined in the Advanced Appearance dialog box refers to

    the color of a text box. But even if they know they cannot change it because many applications use only the WndForeground color and then

    display white text on white background. So nobody can claim that user settings are currently respected. The default is white not because

    most users like it but because the paper is white and in the past application had difficulty with printing if the background color of the

    screen was different to the paper color. But nowadays this problem is gone and there is no need to always use white background in WPF.

    WPF text box selection color missing:
    The lack to define a selection color is the single biggest shortcoming in WPF. To illustrate this it is necessary to define a view


    UserDefSelCol = The 'selected items' color the user has defined in the Advanced Appearance dialog box

    WndForeground =  The 'Window' font color the user has defined in the Advanced Appearance dialog box

    WndBackground = The 'Window' color the user has defined in the Advanced Appearance dialog box

    First take note that there is no specific color defined in Advanced Appearance dialog box for a text box so it is not possible to

    disrespect the users settings for text boxes. The WndForeground and WndBackground colors are only used because these are the closest

    available user defined colors. An application may accommodate much more specific user options to present the application in such color

    settings as really preferred by the user.

    There is only one WndBackground and one WndForeground color defined. If it would be always required to respect the user settings then what

    is the need of Foreground and Background properties in WPF. This would surely diminish the richness of WPF. This would mean an application

    cannot let the user choose from a number of application themes because if the theme alters the background color of TextBox the selection

    may no longer be clearly visible.

    Currently with .Net 3.5 and .Net 4 beta it is not possible to create application themes in a satisfactory way. By application theme I mean

    a xaml resource that overrides the styles for all controls used in the application including TextBox/TextBoxBase. If the UserDefSelCol is

    violet and I set in my application theme the TextBox background to violet the selection will no longer be visible. Even if the selection

    color and the background colors are not the same, often the selection is hard to see because the selection color is too close to the

    background color. Once the background color is changed  the selection color needs to be adjusted to provide sufficient contrast to see the

    selection clearly. But unfortunately there is currently no way to set the selection color of a TextBox object.

    There are two possibilities to solve this problem in WPF:
    A: Implement an algorithm that always automatically creates a clearly visible selection color depending on the actual background color of

    the text box at the time of selection.
    B. Implement a TextBoxBase.SelectionColor property


    Saturday, September 12, 2009 1:30 AM
  • Any news on this?
    Thursday, April 3, 2014 7:11 AM