我想在 datagrid wpf 中获得一个单元格的值,我像 2,3 等那样实现这个。然后我想将一个 int 值与这个单元格的值进行比较,但我无法获得单元格的值。如何获取单元格的值?我的代码:
DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]);
if (row != null)
{
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(row);
DataGridCell cell1 = presenter.ItemContainerGenerator.ContainerFromIndex(2) as DataGridCell;
DataGridCell cell2 = presenter.ItemContainerGenerator.ContainerFromIndex(4) as DataGridCell;
DataGridCell cell3 = presenter.ItemContainerGenerator.ContainerFromIndex(6) as DataGridCell;
SMBPModelDataContext db = new SMBPModelDataContext();
StoreDistributionInformation psaRow = MyDataGrid.SelectedItem as StoreDistributionInformation;
if (psaRow.Day1 != Convert.ToInt32((cell1.Content)))
{
}
我在标题中出现此错误:psaRow.Day1 != Convert.ToInt32((cell1.Content))
提前致谢