CustomSearchBox.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Collections.Generic; 6 using System.Windows; 7 using System.Windows.Automation.Peers; 8 using System.Windows.Controls; 9 10 namespace PowerLauncher 11 { 12 public sealed class CustomSearchBox : TextBox 13 { 14 public List<UIElement> ControlledElements { get; } = new List<UIElement>(); 15 16 protected override AutomationPeer OnCreateAutomationPeer() 17 { 18 return new AutoSuggestTextBoxAutomationPeer(this); 19 } 20 21 internal sealed class AutoSuggestTextBoxAutomationPeer : TextBoxAutomationPeer 22 { 23 public AutoSuggestTextBoxAutomationPeer(CustomSearchBox owner) 24 : base(owner) 25 { 26 } 27 28 protected override List<AutomationPeer> GetControlledPeersCore() 29 { 30 var controlledPeers = new List<AutomationPeer>(); 31 foreach (UIElement controlledElement in ((CustomSearchBox)Owner).ControlledElements) 32 { 33 controlledPeers.Add(UIElementAutomationPeer.CreatePeerForElement(controlledElement)); 34 } 35 36 return controlledPeers; 37 } 38 } 39 } 40 }