C# 当焦点从另一个单元格移动时,如何处理DataGridComboxColumn单元格以更改其值

C# 当焦点从另一个单元格移动时,如何处理DataGridComboxColumn单元格以更改其值,c#,datagrid,C#,Datagrid,///我在工作中使用的是datagrid,使用的是键盘上的默认导航,但在DataGridComboxColumn上导航不起作用 我写了一个代码,将同一列中的一个单元格更改为另一个单元格,但为此,我使用了predictfocus(focusnavigationdirection.down),我可以更改单元格的焦点,但combobox值也在更改。任何人都可以帮我解决这个问题/// ///# /// 我不希望当从另一个单元格聚焦时,comboboxcolumn值发生更改,提前感谢/// private

///我在工作中使用的是datagrid,使用的是键盘上的默认导航,但在
DataGridComboxColumn
上导航不起作用
我写了一个代码,将同一列中的一个单元格更改为另一个单元格,但为此,我使用了predictfocus(focusnavigationdirection.down),我可以更改单元格的焦点,但combobox值也在更改。任何人都可以帮我解决这个问题/// ///#

/// 我不希望当从另一个单元格聚焦时,
comboboxcolumn
值发生更改,提前感谢///

private void DataGrid1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key.Equals(Key.Down))
            {
                DependencyObject dep = (DependencyObject)e.OriginalSource;
                //here it failed to get the datagridcell if it is a datagridcomboboxcolumn
                if (dep is DataGridCell)
                {
                    dep = GetDataGridRowandColumn(dep);
                }
                //by using visual tree helper i get the datagridcell
                else
                {
                    var cell = dep;                       
                    while (dep.GetType() != typeof(DataGridCell))
                    {
                        dep = VisualTreeHelper.GetParent(dep);
                    }
                    var DGC = dep;
                    dep = GetDataGridRowandColumn(dep);
                    //this code changing the focus with in the column from one row to another but also changing the combobox value one to next value
                    var NextCell = (DGC as DataGridCell).PredictFocus(FocusNavigationDirection.Down);
                    var CellType = NextCell;
                    if (NextCell == null)
                    {
                        return;
                    }                       
                        DataGridCellInfo info = new DataGridCellInfo(dataGrid1.Items[GlobalClass.DatagridRow.GetIndex() + 1], GlobalClass.DatagridColumn);
                        SpecificCellSelection(info);                       
                }
            }   
        }
      private DependencyObject GetDataGridRowandColumn(DependencyObject dep)
            {
                GlobalClass.DataGridCell = dep as DataGridCell;
                GlobalClass.DatagridColumn = dataGrid1.Columns[(dep as DataGridCell).Column.DisplayIndex];
                while (dep != null & !(dep is DataGridRow))
                {
                    dep = VisualTreeHelper.GetParent(dep);
                }
                if (dep is DataGridRow)
                {
                    GlobalClass.DatagridRow = dep as DataGridRow;
                }

                return dep;
            }
     private void SpecificCellSelection(DataGridCellInfo info)
            {
                dataGrid1.SelectedCells.Clear();
                dataGrid1.SelectedCells.Add(info);
                dataGrid1.CurrentCell = dataGrid1.SelectedCells[0];
                GlobalClass.DatagridRow = null;
                GlobalClass.DatagridColumn = null;
            }
///