// This method is called from DataGrid.OnBeginningEdit/OnCommittingEdit/OnCancelingEdit // Raises Invoked event when cell begin/cancel/commit edit internal void RaiseAutomationCellInvokeEvents(DataGridColumn column, DataGridRow row) { DataGridItemAutomationPeer dataGridItemAutomationPeer = GetOrCreateItemPeer(row.Item); if (dataGridItemAutomationPeer != null) { DataGridCellItemAutomationPeer cellPeer = dataGridItemAutomationPeer.GetOrCreateCellItemPeer(column); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } } }
// This method is called from DataGrid.OnSelectedCellsChanged // Raises the selection events when Cell selection changes internal void RaiseAutomationCellSelectedEvent(SelectedCellsChangedEventArgs e) { // If the result of an AddToSelection or RemoveFromSelection is a single selected cell, // then all we raise is the ElementSelectedEvent for single item if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) && this.OwningDataGrid.SelectedCells.Count == 1 && e.AddedCells.Count == 1) { DataGridCellItemAutomationPeer cellPeer = GetCellItemPeer(e.AddedCells[0]); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } } else { int i; if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection)) { for (i = 0; i < e.AddedCells.Count; i++) { DataGridCellItemAutomationPeer cellPeer = GetCellItemPeer(e.AddedCells[i]); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } } if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection)) { for (i = 0; i < e.RemovedCells.Count; i++) { DataGridCellItemAutomationPeer cellPeer = GetCellItemPeer(e.RemovedCells[i]); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } } }