Good afternoon,
I have a custom editor style for the XamTextEditor like this:
<Style TargetType="{x:Type igEditors:XamTextEditor}" x:Key="clientInstitutionEditorStyle"> <Setter Property="EditTemplate"> <Setter.Value> <ControlTemplate TargetType="{x:Type igEditors:XamTextEditor}"> <TextBox Text="{Binding DataItem.clientInstitutionName, Mode=TwoWay}" x:Name="clientInstitutionName" TextChanged="TypeAhead_TextChanged_Handler" PreviewKeyDown="TypeAhead_PreviewKeyDown_Handler" ></TextBox> </ControlTemplate> </Setter.Value> </Setter> </Style>
And I use it like this in my XamDataGrid:
<igDP:Field Name="clientInstitutionName" Label="client Institution" Width="120" > <igDP:Field.Settings> <igDP:FieldSettings EditAsType="{x:Type sys:String}" EditorType="{x:Type igEditors:XamTextEditor}" EditorStyle="{StaticResource clientInstitutionEditorStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
It works perfectly but users have to click once after pressing F2 to really get into the TextBox contained into the editor, is there anyway to make that the internal textbox gets the focus when users press F2 on the active cell?
Thanks,
Hello Jairo,
Thank you for your post!
I have been looking into it and it seems that I am missing something from your scenario. Once a user clicks on a Cell is becomes active then when the F2 button is pressed the Cell enters edit mode. This is the default behavior for entering editor mode, when the F2 button is pressed.
Would you please provide me with some additional information about the functionality you are using?
I have created a small sample application, using the code snippets you have provided. Would you please modify it with the functionality you are using, so it reproduces the behavior you have mentioned? This way I would be able to further research this issue for you.
Thank you for the cooperation. Looking forward to hearing from you.
Thanks for the quick reply!
It is my fault, I forgot to mention that I am currently using version 11.1 (sorry for that) so I took your sample code and changed it to use v11.1 and Visual Studio 10 and it shows exactly the same behavior I described, it means I enter the cell with F2 but to really be able to type I still have to click it again. Even double clicking the cell won't put the focus on the text box, it changes into edit Mode but the textbox doesn't have the focus.
Thank you for the provided information.
I have been looking into your issue. The default behavior when an editor in the XamDataGrid enters edit mode it would select the entire text in the cell.
When you create a custom EditTemplate for the Editor the above mentioned functionality is lost. This is why you have to click one more time, in order to place the cursor in the cell, that is being edited.
In order to use the custom implementation of the EditTemplate and have the default behavior of a cell entering edit mode, I can suggest to handle the Loaded event of the TextBox in the EditTemplate.
In the handler of the event you can call the Focus and SelectAll methods of the TextBox. This way when the user presses the F2 button the text in the cell would be selected and the editing can start without second click on the cell.
I have implemented the above mentioned functionality in a small sample application. Please find the attachment and feel free to let me know if you have any further questions on this matter.
Hi Gergana,
We are almost there. I applied the changes you explained and it worked well till a certain point where it broke another existing feature. I don't know if you can help me with this but the whole point of this is to provide the user with a list when they type something then they can choose an item from the list (just as google does when you start searching for some words...). This type ahead list is displayed when the user types something in the XamTextEditor textbox and it was working really well but when I added the Loaded event to it the list disappears when I press the "down arrow" (which is supposed to allow users to browse the list so they can pick any item from it).
So I changed the project to implement a basic type ahead list and it exposes the same problem I just explained, but If I remove the "Load" attribute from the XamTextEditorStyle it works ok (just that users have to double click the editor to focus the textbox and which was the original point of this thread).
So please test it as it is and you will see the popUp list disappear when you press the "down arrow" (at least it does here with version 11.1) and if you remove the load event[Loaded="WorkersName_Loaded"] from the style you will see how it is supposed to work.
Thanks for your time, help and patience.
I have been looking into the sample application you have provided. I was not able to run the application and it seems that some of the custom implementation of the dropdown list is missing. Would you please double check the sample application?
My fault, please excuse me.
Here is the whole project.
Please notice that the problem with the popUp list only happens the first time a cell in the grid goes into edit mode and the down arrow is pressed, after that it behaves as expected.
Thank you for the provided sample application.
I have been looking into it and what I can suggest is to use the XamComboEditor, in order to achieve an autocomplete TextBox functionality. I have created a small sample application for you to show you this functionality.
In the sample application I have a XamComboEditor in one of the columns of the XamDataGrid. I have also added the default styles for the XamComboEditor. In this styles I have set the Visibility property to Collapsed to all of the ToggleButtons. Then I have handled the TextChanged event of the editor. There I set the IsDropDownOpen property to true. This way when the user starts to type in the TextBox the dropdown will show.
Also I have set the DropDownResizeMode property to None, in order to hide the PopupResizeBar at the bottom of the XamComboEditor.
Regarding the version you are using, what I can suggest is to update your project to the latest version of Infragistics - 14.1, because the support for Infragistics 11.1 has expired. For more information about the Product Lifecycle you can taka at the following link: http://www.infragistics.com/help/product-lifecycle.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Thanks a lot for the new proposed solution, I really appreaciate it.
I will see if I can change our popUp view and use your XamComboEditor approach instead.
Only one more question:
1. Did you get to see the behavior I told you about? (the popUpView disappears when pressing the "down arrow").