Код: Выделить всё
if (!_viewModel.ItemExists(codPro))
{
MessageBox.Show(
"O item não existe na tabela de itens.",
"Erro",
MessageBoxButton.OK,
MessageBoxImage.Error
);
e.Cancel = true;
(sender as DataGrid).Dispatcher.BeginInvoke((Action)(() =>
{
var dataGrid = sender as DataGrid;
if (dataGrid != null)
{
dataGrid.SelectedCells.Clear();
dataGrid.SelectedCells.Add(new DataGridCellInfo(e.Row.Item, e.Column));
dataGrid.CurrentCell = new DataGridCellInfo(e.Row.Item, e.Column);
dataGrid.BeginEdit();
var cellContent = dataGrid.Columns[e.Column.DisplayIndex].GetCellContent(e.Row);
if (cellContent != null)
{
var cell = cellContent.Parent as DataGridCell;
if (cell != null)
{
cell.Focus();
var textBox = cellContent as TextBox;
if (textBox != null)
{
textBox.SelectAll();
}
}
}
}
}));
return;
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... n-e-cancel
Мобильная версия