diff options
author | Bret Johnson <bret.johnson@microsoft.com> | 2018-06-25 19:04:53 +0300 |
---|---|---|
committer | Bret Johnson <bret.johnson@microsoft.com> | 2018-06-25 19:04:53 +0300 |
commit | 9e7b2905f6936d846b4d17231b00a73f09ecee1f (patch) | |
tree | 86af675722c9760605bf458f5042f3d4792a235b | |
parent | af2540cb0b6a1c1e82c4f7ec8949565f6677e631 (diff) |
[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.
-rw-r--r-- | Xwt.WPF/Xwt.WPFBackend/ValuesContainer.cs | 13 |
1 files changed, 12 insertions, 1 deletions
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); } + + /// <summary> + /// 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. + /// </summary> + public override string ToString () + { + if (values.Length > 0 && values[0] is string) + return (string) values[0]; + else return base.ToString (); + } } } |