/// <summary> /// Raise an automation peer event for the selection of a day button. /// </summary> /// <param name="calendar"> /// The GlobalCalendar associated with this automation peer. /// </param> /// <param name="date">The selected date.</param> /// <param name="eventToRaise">The selection event to raise.</param> private static void RaiseDayButtonSelectionEvent(GlobalCalendar calendar, DateTime date, AutomationEvents eventToRaise) { GlobalCalendarDayButton button = calendar.FindDayButtonFromDay(date); if (button != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(button); if (peer != null) { peer.RaiseAutomationEvent(eventToRaise); } } }
/// <summary> /// Retrieves a UI automation provider for each child element that is /// selected. /// </summary> /// <returns>An array of UI automation providers.</returns> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> IRawElementProviderSimple[] ISelectionProvider.GetSelection() { IRawElementProviderSimple[] selection = null; TreeViewItem selectedItem = OwnerTreeView.SelectedContainer; if (selectedItem != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(selectedItem); if (peer != null) { selection = new IRawElementProviderSimple[] { ProviderFromPeer(peer) }; } } return selection ?? new IRawElementProviderSimple[] { }; }
protected override List<AutomationPeer> GetChildrenCore() { TreeView owner = OwnerTreeView; ItemCollection items = owner.Items; if (items.Count <= 0) { return null; } List<AutomationPeer> peers = new List<AutomationPeer>(items.Count); for (int i = 0; i < items.Count; i++) { TreeViewItem element = owner.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewItem; if (element != null) { peers.Add( FrameworkElementAutomationPeer.FromElement(element) ?? FrameworkElementAutomationPeer.CreatePeerForElement(element)); } } return peers; }