From 9e7b2905f6936d846b4d17231b00a73f09ecee1f Mon Sep 17 00:00:00 2001 From: Bret Johnson Date: Mon, 25 Jun 2018 12:04:53 -0400 Subject: [a11y][WPF] Fixed combo box item automation names This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/596863. Previously, we showed Xwt.WPFBackend.ValueConverter (the class name) as the automation Name for combo box items, but now properly show the item text as the Name. At first, I tried replacing the default ComboBox and ComboBoxItem automation peers, but there was a fair amount of complexity around that, making the pair of peers properly work together. In the end, overriding ToString turned out to be a much simpler and safer fix. --- Xwt.WPF/Xwt.WPFBackend/ValuesContainer.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Xwt.WPF/Xwt.WPFBackend/ValuesContainer.cs b/Xwt.WPF/Xwt.WPFBackend/ValuesContainer.cs index 9380d274..a2d4fd37 100644 --- a/Xwt.WPF/Xwt.WPFBackend/ValuesContainer.cs +++ b/Xwt.WPF/Xwt.WPFBackend/ValuesContainer.cs @@ -1,4 +1,4 @@ -// +// // ValuesContainer.cs // // Author: @@ -67,5 +67,16 @@ namespace Xwt.WPFBackend if (handler != null) handler (this, e); } + + /// + /// ToString is used by the default ComboBoxItem automation peer to get the automation Name for the item. + /// Normally, we want to be the same as the text in the combo, the first value. + /// + public override string ToString () + { + if (values.Length > 0 && values[0] is string) + return (string) values[0]; + else return base.ToString (); + } } } -- cgit v1.2.3