Reputation: 25
I found only the way to select all text in the code behind. But i want to do it in the style of itself.
Is it possible to do that?
Upvotes: 1
Views: 954
Reputation: 69959
There is no property that you can set to select all of the Text
in a TextBlock
or TextBox
. Selecting all text must be accomplished using the TextBoxBase.SelectAll
Method. What you could do in a Style
is to set an event handler for the GotFocus
event, where the handler code would call SelectAll
, but your handler would of course need to be in code and not XAML.
One other possibility would be for you to create an Attached Property that would select the text whenever the TextBox
gets focus, but again it's not possible to do this in XAML.
Upvotes: 1