protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
{
var uiElement = ((DoubleTextBox)sender);
uiElement.ValueChanged += OnValueChanged;
uiElement.Focus();
if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null)
{
uiElement.SelectAll();
}
else
{
if (PreviewInputText == null || char.IsLetter(PreviewInputText.ToString(), 0))
{
var index = uiElement.Text.Length;
uiElement.Select(index + 1, 0);
return;
}
double value;
double.TryParse(PreviewInputText.ToString(), out value);
uiElement.Value = value;
uiElement.Text = PreviewInputText.ToString();
var caretIndex = uiElement.Text.IndexOf(PreviewInputText.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal);
uiElement.Select(caretIndex + 1, 0);
}
PreviewInputText = null;
} |