Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 public static void RegisterFocusEvents(DependencyObject obj)
 {
     if (AutomationPeerCache.GetIsAutomationFocused(obj))
     {
         return;
     }
     AutomationPeerCache.RegisterFocusEvents(obj, "IsKeyboardFocused");
 }
Exemplo n.º 3
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");
 }