private void dg_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            string columnName = e.Column.Header.ToString();

            if (e.Column.Header is TextBlock)
            {
                columnName = ((TextBlock)e.Column.Header).Text;
            }
            string originColumnName = columnName;

            TextBox editingTextBox = e.EditingElement as TextBox;

            dataRowView = e.Row.Item as DataRowView;

            if (editingTextBox != null && dataRowView != null)
            {
                string oldValue = dataRowView[columnName].ToString();
                string newValue = editingTextBox.Text;
                if (!string.Equals(oldValue, newValue))
                {
                    try
                    {
                        string     featureId  = dataRowView[FeatureLayerAdapter.FeatureIdColumnName].ToString();
                        DataColumn dataColumn = dataRowView.DataView.Table.Columns[columnName];
                        if (dataColumn.DataType == typeof(Uri))
                        {
                            dataRowView.Row[columnName] = new Uri(newValue, UriKind.RelativeOrAbsolute);
                        }
                        else
                        {
                            dataRowView.Row[columnName] = newValue;
                        }
                        EditDataChange editDataChange = new EditDataChange(oldValue, newValue, originColumnName, featureId, editingTextBox.Parent as DataGridCell, dataRowView.Row);
                        viewModel.EditDataChanges.Add(editDataChange);
                    }
                    catch (Exception ex)
                    {
                        editingTextBox.Text = oldValue;
                        System.Windows.Forms.MessageBox.Show(ex.Message, "Warning");
                        GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                    }
                }
            }
        }
 private void dbfViewer_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (Keyboard.Modifiers == ModifierKeys.Control)
     {
         if (e.Key == Key.Z)
         {
             EditDataChange resultEditDataChange = viewModel.EditDataChanges.LastOrDefault(edc => edc.ShortcutKeyMode == EditDataShortcutKeyMode.Undo);
             if (resultEditDataChange != null)
             {
                 resultEditDataChange.Undo();
             }
         }
         else if (e.Key == Key.Y)
         {
             EditDataChange resultEditDataChange = viewModel.EditDataChanges.FirstOrDefault(edc => edc.ShortcutKeyMode == EditDataShortcutKeyMode.Redo);
             if (resultEditDataChange != null)
             {
                 resultEditDataChange.Redo();
             }
         }
     }
 }