Enter key behaviour in DoubleEditBox in a Datagrid

Editors for WPF Forum

Posted 8 years ago by Aled Hughes - Principal Software Engineer, Control Techniques Ltd.
Version: 11.1.0545
Avatar
Hi,
I'm using a DoubleEditBox within the CellEditingTemplate of a DataGrid column but have an issue in that I have to press the enter key twice to commit the edit. I.e. I select the cell, press F2 to go to edit mode then I have to tab to be able to type a value in, then I have to press ENTER twice to commit the value.

This doesn't happen with the standard TextBox. How can I avoid having to press enter twice?

<DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTemplateColumn Header="APEdit" Width="80">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Value}"/>    
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
            <DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <ae:DoubleEditBox Minimum="0.0" Maximum="9999.9" Value="{Binding Value}" SpinnerVisibility="Visible" PartValueCommitTriggers="SpinnerChangeOrEnterKeyDown"  />
                </DataTemplate>
            </DataGridTemplateColumn.CellEditingTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>

Comments (2)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Aled,

You would need to set the PartValueCommitTriggers property on the DoubleEditBox to be "SpinnerChange,StringValueChange" (i.e. PartValueCommitTriggers.SpinnerChange | PartValueCommitTriggers.StringValueChange). Basically you want to exclude the EnterKeyDown option.


Actipro Software Support

Posted 8 years ago by Aled Hughes - Principal Software Engineer, Control Techniques Ltd.
Avatar
Thanks that has worked. I've set it to just SpinnerChange since I don't want the backing field to update as someone types in a value.
The latest build of this product (v2019.1 build 0682) was released 30 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.