Tag Archives: textbox selectall

Thinking in WPF: more attached properties

In my last blog post, I wrote an article about attached properties. Today at work, I encountered a problem that can be solved in a nice way using an attached property. Because the functionality I wanted to implement is also very simple, I decided to blog about it to give a concrete example.

I wanted to use a TextBox to allow the user of my application to give a description for any item he selects in a TreeView. Because the TextBox’s content could be changed very frequently by the user, I thought it might be useful to select all the TextBox’s text when the user click in the control (so that as soon as he types something, the old content is cleared).

In this article, I will describe various way to implement this feature and I will detail the way I prefer, using of course an attached property !

Continue reading Thinking in WPF: more attached properties