/// <summary> /// Property changed called back for IsSelected property /// </summary> private static void OnIsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { RibbonTab ribbonTab = (RibbonTab)sender; if (ribbonTab.IsSelected) { ribbonTab.OnSelected(new RoutedEventArgs(Selector.SelectedEvent, ribbonTab)); } else { ribbonTab.OnUnselected(new RoutedEventArgs(Selector.UnselectedEvent, ribbonTab)); } RibbonTabHeader header = ribbonTab.RibbonTabHeader; if (header != null) { header.CoerceValue(RibbonTabHeader.IsRibbonTabSelectedProperty); } // Raise UI automation events on this RibbonTab if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) || AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection)) { RibbonTabAutomationPeer peer = RibbonTabAutomationPeer.CreatePeerForElement(ribbonTab) as RibbonTabAutomationPeer; if (peer != null) { peer.RaiseTabSelectionEvents(); } } }