Ejemplo n.º 1
0
        private static void OnIsAutomationFocusedChanged(DependencyObject dobj, DependencyPropertyChangedEventArgs e)
        {
            if (AutomationPeerCache._objThatIsBinding == dobj)
            {
                return;
            }
            AutomationPeer automationPeer = AutomationPeerCache.GetAutomationPeer(dobj) ?? UIElementAutomationPeer.FromElement(dobj as UIElement);

            if (automationPeer == null)
            {
                return;
            }
            if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged))
            {
                automationPeer.RaisePropertyChangedEvent(SelectionItemPatternIdentifiers.IsSelectedProperty, e.OldValue, e.NewValue);
                automationPeer.RaisePropertyChangedEvent(AutomationElementIdentifiers.HasKeyboardFocusProperty, e.OldValue, e.NewValue);
            }
            if (AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged))
            {
                automationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
            }
            if (!(automationPeer is ItemAutomationPeer) || !AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected))
            {
                return;
            }
            automationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected);
        }
Ejemplo n.º 2
0
        public static T Create <T>(UIElement element, params object[] args) where T : AutomationPeer
        {
            AutomationPeer automationPeer = AutomationPeerCache.GetAutomationPeer((DependencyObject)element);

            if (automationPeer == null)
            {
                if (args.Length == 0)
                {
                    automationPeer = (AutomationPeer)Activator.CreateInstance(typeof(T), new object[1]
                    {
                        (object)element
                    });
                }
                else
                {
                    automationPeer = (AutomationPeer)Activator.CreateInstance(typeof(T), args);
                }
                if (automationPeer != null)
                {
                    AutomationPeerCache.SetAutomationPeer((DependencyObject)element, automationPeer);
                    AutomationPeerCache.RegisterFocusEvents((DependencyObject)element);
                }
            }
            return(automationPeer as T);
        }
Ejemplo n.º 3
0
 public static void RegisterFocusEvents(DependencyObject obj)
 {
     if (AutomationPeerCache.GetIsAutomationFocused(obj))
     {
         return;
     }
     AutomationPeerCache.RegisterFocusEvents(obj, "IsKeyboardFocused");
 }
Ejemplo n.º 4
0
 public static void RegisterFocusEvents(DependencyObject obj, AutomationPeer associatedPeer)
 {
     if (AutomationPeerCache.GetIsAutomationFocused(obj))
     {
         return;
     }
     if (AutomationPeerCache.GetAutomationPeer(obj) == null && UIElementAutomationPeer.FromElement(obj as UIElement) == null)
     {
         AutomationPeerCache.SetAutomationPeer(obj, associatedPeer);
     }
     AutomationPeerCache.RegisterFocusEvents(obj, "IsKeyboardFocused");
 }