diff options
-rw-r--r-- | Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs b/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs index 4ca5c95e..2e010c4c 100644 --- a/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs +++ b/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs @@ -1,4 +1,4 @@ -// +// // ExTreeViewItem.cs // // Author: @@ -26,7 +26,10 @@ // THE SOFTWARE. using System; +using System.Collections.Generic; +using System.Linq; using System.Windows; +using System.Windows.Automation.Peers; using System.Windows.Controls; using System.Windows.Input; using SWC = System.Windows.Controls; @@ -230,12 +233,38 @@ namespace Xwt.WPFBackend //We can't allow TreeViewItem(our base class) to get this message(OnGotFocus) because it will also select this item which we don't want }
- private bool CtrlPressed
- {
- get
- {
- return Keyboard.IsKeyDown (WKey.RightCtrl) || Keyboard.IsKeyDown (WKey.LeftCtrl);
- }
- }
+ private bool CtrlPressed + { + get + { + return Keyboard.IsKeyDown (WKey.RightCtrl) || Keyboard.IsKeyDown (WKey.LeftCtrl); + } + } + + protected override AutomationPeer OnCreateAutomationPeer () + { + return new ExTreeViewItemAutomationPeer (this); + } + + class ExTreeViewItemAutomationPeer : TreeViewItemAutomationPeer + { + public ExTreeViewItemAutomationPeer (ExTreeViewItem owner) : base (owner) + { + } + + protected override List<AutomationPeer> GetChildrenCore () + { + List<AutomationPeer> defaultChildren = base.GetChildrenCore (); + if (defaultChildren == null) + return null; + + // We only want to include TreeView items in the a11y tree, not their constituent image/text/etc controls - + // for one thing including all controls messes up the "item 3 of 5" style counts announced by the + // narrator, as those controls would be included in the counts + List<AutomationPeer> children = defaultChildren.Where ( + child => child is TreeViewItemAutomationPeer || child is TreeViewDataItemAutomationPeer).ToList (); + return children; + } + } } } |