Hello,
i'm experiencing some issues with custom EditTemplate in the XamDataGrid:
my render template is set to a simple TextBlock, and my edit template to a TextBox. The problem is that when I click on a cell (or tab to navigate between cells) I do not get focus into the TextBox although the cell template is switched to the edit template.
In the following screenshot we can se that the caret is not visible in the active cell, even if the text is rendered in a textbox (EditTemplate):
The following is the xaml code for this FieldSetting:
<DataPresenter:FieldSettings x:Key="TextBoxEditableField"> <DataPresenter:FieldSettings.EditorStyle> <Style TargetType="{x:Type Editors:XamTextEditor}"> <!-- Edit template: textBox --> <Setter Property="EditTemplate"> <Setter.Value> <ControlTemplate> <TextBox x:Name="EditBox" Text="{Binding [This binding works]}" /> </ControlTemplate> </Setter.Value> </Setter> <!-- Render template: simple textBlock --> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <TextBlock Text="{Binding [This binding works]}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> </DataPresenter:FieldSettings.EditorStyle></DataPresenter:FieldSettings>
I would like to get focus in the "EditBox" TextBox when the edit template is rendered, do you know how I can achieve it?
If needed, enclosed is the sample project I used to render the above screenshot.
Thanks by advance!
Awen
Hello Awen,
Thank you for the sample. XamTextEditor control is specially accommodate to work with xamDataGrid, and automatically enters edit mode when you focus it. I have been looking into your sample and I noticed that you set completely new Edit template for the XamTextEditor and this may change some of the default functionality that the editor provides. Based on this I can suggest you use the default EditTemplate of XamTextEditor and modify only these parts from it that you want. You can find the default templates of our controls on your computer in the file: C:\Program Files (x86)\Infragistics\NetAdvantage 2011.2\WPF\DefaultStyles\Editors\EditorsGeneric_Express.xaml .
For further reference please have a look at the attached sample which I modified for you.
If you have any additional questions on this matter please feel free to ask.
Hello Elena,
Thank you for the fast reply :)
Based on the modifications you made in my sample I noticed the "PART_FocusSite" name on the TextBox in the template.As it looked like a generic name, I tried to just change my TextBox name (which was "EditBox") to "Part_FocusSite" and it is now working perfectly.
Thanks a lot!