We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PreviewTextInput on SfDataGrid:GridTemplateColumn

Thread ID:





128299 Jan 12,2017 07:59 PM UTC Jan 17,2017 03:26 AM UTC WPF 1
Tags: SfDataGrid
Brandon Hankins
Asked On January 12, 2017 07:59 PM UTC

I have a somewhat obscure issue that I am unable to find a solution to based on example code or existing documentation on the SfTextBoxExt of SfDataGrid controls.

I have a solution that requires a bulk input screen using the SfDataGrid with multiple nested SfTextBoxExt controls. Is there anyway to pass the PreviewTextInput to the SfTextBoxExt nested in the GridTemplateColumn?

Further, is it possible to paste values into the nested SfTextBoxExt control? The customer has both of these as requirements, and based on the currently available documentation and samples it appears that we cannot do either.



        <DataTemplate x:Key="MaterialTypeSelectionTemplate">

            <sfInput:SfTextBoxExt x:Name="MaterialTypes"
                                  Style="{DynamicResource DefaultTextBox}"
                                  AutoCompleteSource="{Binding MaterialSetup.Materials}"
                                  SelectedItem="{Binding MaterialType, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"                                  
                                  syncfusion:FocusManagerHelper.FocusedElement="True" />


        <DataTemplate x:Key="MaterialTypeDisplayTemplate">

            <TextBlock Margin="8" Text="{Binding MaterialType.Description}" />



Here is my OnTextInput override:

        protected override void OnTextInput(TextCompositionEventArgs e)
            if (!SelectionController.CurrentCellManager.HasCurrentCell)
            var rowColumnIndex = SelectionController.CurrentCellManager.CurrentRowColumnIndex;

            var row = this.ResolveToRowIndex(rowColumnIndex.RowIndex);

            RowGenerator rowGenerator;

            FieldInfo fieldInfo = typeof(SfDataGrid).GetField("RowGenerator", BindingFlags.NonPublic | BindingFlags.Instance);

            rowGenerator = fieldInfo.GetValue(this) as RowGenerator;

            var dataRow = rowGenerator.Items.FirstOrDefault(item => item.RowIndex == rowColumnIndex.RowIndex);
            if (dataRow != null && dataRow is DataRow)
                var dataColumn = dataRow.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == rowColumnIndex.ColumnIndex);
               char text;

                char.TryParse(e.Text, out text);

                if (dataColumn != null && !(dataColumn.GridColumn is GridTemplateColumn) && !dataColumn.IsEditing && SelectionController.CurrentCellManager.BeginEdit())


Gobikrishnan Murugesan [Syncfusion]
Replied On January 17, 2017 03:26 AM UTC

Hi Brandon, 
We have checked your provided code snippet (Datatemplate definition and OnTextInput override method). Based on our understanding we have created sample for your requirement. If your requirement is different from us then could you please provide more information about your query like explaining about the exact requirement or modify below sample and replication steps to reproduce the requirement? It would help us to proceed further. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon