void userGrid_MouseClick(object sender, MouseButtonEventArgs e) { try { IInputElement element = e.MouseDevice.DirectlyOver; if (element != null && element is FrameworkElement) { if (((FrameworkElement)element).Parent is Microsoft.Windows.Controls.DataGridCell) { var grid = sender as Microsoft.Windows.Controls.DataGrid; if (grid != null && grid.SelectedItems != null && grid.SelectedItems.Count == 1) { for (int i = 0; i < grid.Columns.Count; i++) { var item = new Microsoft.Windows.Controls.DataGridCellInfo(grid.Items[grid.SelectedIndex], grid.Columns[0]); var col = item.Column as Microsoft.Windows.Controls.DataGridColumn; var fc = col.GetCellContent(item.Item); if (fc is CheckBox) { CheckBox checkCell = (CheckBox)fc; if (checkCell != null && checkCell.IsChecked == false) { checkCell.IsChecked = true; var addItemId = (ChargeData)item.Item; selectUserNameList.Add(addItemId.id); } else if (checkCell != null && checkCell.IsChecked == true) { checkCell.IsChecked = false; var delItemId = (ChargeData)item.Item; selectUserNameList.Remove(delItemId.id); } } } if (selectUserNameList.Count > 0) { button1.IsEnabled = true; } } } } } catch (Exception ex) { string strError = ex.ToString(); ErrorCollection.GetInstance().SetErrorInfo(strError); } }
public static DataGridCell GetCell(DataGridCellInfo dataGridCellInfo) { if (!dataGridCellInfo.IsValid) { return null; } var cellContent = dataGridCellInfo.Column.GetCellContent(dataGridCellInfo.Item); if (cellContent != null) { return (DataGridCell)cellContent.Parent; } else { return null; } }
internal bool EqualsImpl(DataGridCellInfo cell) { return (cell._item == _item) && (cell._column == _column) && (cell.Owner == Owner); }
internal bool EqualsImpl(DataGridCellInfo cell) { return((cell._item == _item) && (cell._column == _column) && (cell.Owner == Owner)); }