错误:无法将类型为“System.Windows.Controls.TextBlock”的对象强制转换为“System.IConvertible”

时间:2013-06-13 22:43:27

标签: c# wpf wpf-controls wpfdatagrid wpftoolkit

我想在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))

提前致谢

0 个答案:

没有答案