Hi,
I have several types of editors on a page. I want when the users TAB to a control or click on it, the entire text or number to be selected.
By default the editors would put the cursor at the beginning of the control.
What do I need to do for the editors to select the entire text or number.
Thanks very much in advance.
Dimitar
Thanks Curtis - we are working on a pretty large project. I'll try to create a simpler, smaller project that reproduces the problem.
I'm not sure what an Edit Edit Control Template is. If you post the XAML which breaks the event handler, I will try to replicate the problem.
Thanks,
This worked well until one of our graphics designers used Blend to create an "Edit Edit Control Template". The event is no longer firing in this case. Is there anyway to add this style to the "Edit Edit Control Template" so the event will fire again?
Thanks Curtis!
We put the code behind in the resource dictionary and that seemed to do it for all editors.
Hello Mitashki,
You can use a style with an EventSetter and a little bit of code behind to get what you want.
In the XAML add the style definition. Change x:Key to a style name if you prefer to apply the style to each instance of an editor rather than have it apply automatically to all XamTextEditors.
<Style x:Key="{x:Type igEditors:XamTextEditor}" TargetType="{x:Type igEditors:XamTextEditor}"> <EventSetter Event="GotFocus" Handler="HandleFocusEditorEvent"/></Style>
In the code-behind add the event handler definition:
private void HandleFocusEditorEvent(object sender, RoutedEventArgs e){ ((XamTextEditor)sender).SelectAll();}
This will cause the XamTextEditor to select all text in itself every time it gains key focus.