0

我正在使用CellEditEnding事件为已编辑的单元格设置新的前景色工具提示。它工作得很好,除了为什么我在数据网格中向下滚动前景色和工具提示在列中移动,这使得它非常无用。

我认为它一定与FrameWork 元素有关,但我不确定如何解决这个问题。

我的代码:

private void myDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
  {
  
    System.Windows.Controls.ToolTip tt = new System.Windows.Controls.ToolTip();
    tt.Content = "My tooltip text";
    FrameworkElement element = (e.Column.GetCellContent(e.Row));
    System.Windows.Controls.DataGridCell chosen = (element.Parent as System.Windows.Controls.DataGridCell);
    chosen.ToolTip = tt;
    chosen.Foreground = new SolidColorBrush(Colors.Red);
  }

谁能告诉我为什么在数据网格中滚动时它会移动(工具提示和颜色)到其他单元格?我应该如何解决它?

或者,如果您对如何为数据网格中的已编辑单元格设置工具提示和前景色有更好的想法,请告诉我。

感谢您提前提供任何帮助;)

4

1 回答 1

1

尝试使用:

<DataGrid Name="SimpleDataGrid" ScrollViewer.CanContentScroll="False" CellEditEnding="SimpleDataGrid_CellEditEnding" />

对于物理单位的卷轴。

有关详细信息,请参阅MSDN

于 2013-06-26T10:52:26.970 回答