Syncfusion GridTemplateColumn первая печатная буква игнорируется - PullRequest
0 голосов
/ 18 сентября 2018

enter image description here У меня есть сетки GridTemplateColumn и GridTextColumn, созданные на странице, когда я вхожу в режим редактирования, столбцы с GridTextColumn не игнорируют первую букву, GridTemplateColumn игнорирует первую букву. например, если я щелкну по столбцу и начну вводить f d s a, я вижу только d s a "f" игнорируется. в GridTextColumn, если я набираю f d s a, я вижу все буквы. f d s a.

Я изменил все GridTemplateColumn на GridTextColumn. но мне сказали не делать этого, нам нужен GridTemplateColumn и найти другое решение.

Код:

var column = new GridTemplateColumn
        {
            MappingName=$"e.Column.MappingName}.
                      nameof(ScribeDevicePropertyViewModel.BindingObject)}",
            HeaderText = headerText,
            SetCellBoundValue = true,
            UseBindingValue = true,
            ImmediateUpdateColumnFilter = true,
            ColumnFilter = ColumnFilter.DisplayText,
            GroupMode = DataReflectionMode.Display,
            FilterRowCondition = FilterRowCondition.Contains,
            CellStyle = grid.TryFindResource("DevicePropertyCellStyle") as 
    Style,
            CellTemplate = 
    grid.TryFindResource("DevicePropertyCellTemplate") as DataTemplate,
            EditTemplateSelector = new 
    ScribeDevicePropertyCellEditTemplateSelector()

    // and in xaml file also:

    <syncfusion:GridTemplateColumn
                        Width="200"
                        CellStyle="{StaticResource DevicePropertyCellStyle}"
                        CellTemplate="{StaticResource 
    DevicePropertyCellTemplate}"
                        EditTemplateSelector="{StaticResource 
                        ScribeDevicePropertyCellEditTemplateSelector}"
                        MappingName="Value" />
        };

1 Ответ

0 голосов
/ 28 сентября 2018

Вы можете выполнить свои требования, написав CustomRenderer для GridTemplateColumn и переопределив метод SetFocus, как показано в приведенном ниже фрагменте кода,

this.AssociatedObject.CellRenderers.Remove("Template");  
this.AssociatedObject.CellRenderers.Add("Template", new CustomGridCellTemplateRenderer());  

public class CustomGridCellTemplateRenderer : GridCellTemplateRenderer  
{  
     protected override void SetFocus(FrameworkElement uiElement, bool needToFocus)  
     {  
          base.SetFocus(uiElement, needToFocus);  
          var focusedElement = FocusManagerHelper.GetFocusedUIElement(CurrentCellRendererElement);  
          TextBox textBox = focusedElement as TextBox;  
          if(textBox == null)  
          {  
              var comboBox = focusedElement as ComboBox;  
              if(comboBox != null && comboBox.IsEditable)  
              {  
                  textBox = (TextBox)GridUtil.FindDescendantChildByType(comboBox, typeof(TextBox));  
              }  
          }  
          if (textBox != null)  
          {  
              if (PreviewInputText == null)  
              {  
                  var index = textBox.Text.Length;  
                  textBox.Select(index + 1, 0);  
                  return;  
              }  
              textBox.Text = PreviewInputText;  
              var caretIndex = (textBox.Text).IndexOf(PreviewInputText.ToString());  
              textBox.Select(caretIndex + 1, 0);  
              PreviewInputText = null;  
          }  
     }  
}  

Пожалуйста, найдите образец для той же ссылки ниже, и, пожалуйста, дайте нам знать, если это поможет вам
http://www.syncfusion.com/downloads/support/directtrac/215268/ze/WPF-678839977

Примечание: я работаю на Syncfusion

...