Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
Focus issue with custom EditTemplate
posted

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

FocusSample.zip
Parents Reply Children
No Data