{"id":283,"date":"2015-12-28T22:35:57","date_gmt":"2015-12-28T20:35:57","guid":{"rendered":"http:\/\/www.webbie.org.uk\/blog\/?p=283"},"modified":"2015-12-28T22:35:57","modified_gmt":"2015-12-28T20:35:57","slug":"msaa-uia-and-wpf","status":"publish","type":"post","link":"https:\/\/www.webbie.org.uk\/blog\/msaa-uia-and-wpf\/","title":{"rendered":"MSAA, UIA and WPF"},"content":{"rendered":"<p>A technical note today for programmers.<\/p>\n<p>Screenreaders (blind users) interact with Windows programs through accessibility APIs. The most modern is <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ee684009.aspx\">UI Automation.<\/a> But the first, and possibly most important still, is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Active_Accessibility\">MSAA, Microsoft Active Accessibility.<\/a> Windows will supply information from one interface to the other system if required, so most of the time you shouldn\u2019t have to worry too much.<\/p>\n<p>I\u2019ve been doing some .Net programs using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Presentation_Foundation\">WPF or XAML<\/a> (that is, not WinForms) and here\u2019s a quick guide to what I\u2019ve found:<\/p>\n<ul>\n<li>Buttons and CheckBoxes work fine just as they are. In fact, don\u2019t set any Automation properties or you\u2019ll get odd-looking controls in MSAA.\n<li>ListBox, ComboBox, TextBox, ProgressBar work fine for their contents just as they are. But:\n<li>Labels don\u2019t label Listbox\/ComboBox\/TextBox\/ProgressBar unless you use LabeledBy.\n<\/ul>\n<p>In C++ applications you associate labels (e.g. \u201cEnter username:\u201d) with the control they are labelling (e.g. a textbox for the username) by using tab order. The label with tab index N labels the control with tab index N+1. So label with tab index 0 provides the name to the combobox with tab index 1. <\/p>\n<p>In WPF you have to set this explicitly using AutomationProperties.LabeledBy, like this:<br \/>\n<code><\/p>\n<pre>\r\n&lt;Label Content=\"A ListBox Control:\" x:Name=\"lblList\">&lt;\/Label>\r\n&lt;ListBox AutomationProperties.LabeledBy=\"{Binding ElementName=lblList}\">\r\n  &lt;TextBlock>Elephant&lt;\/TextBlock>\r\n  &lt;TextBlock>Koala&lt;\/TextBlock>\r\n&lt;\/ListBox>\r\n<\/pre>\n<p><\/code><br \/>\nNote the funky \u201cBinding\u201d code \u2013 you can\u2019t just use the x:Name of the label. Notice also that your Label must have an x:Name! You can also use a TextBlock instead of a label. Generally the pattern is:<br \/>\n<code><\/p>\n<pre>\r\n&lt;TextThing Content=\u201dThe label for the other control\u201d x:Name=\u201dtextThingLabel\u201d \/>\r\n&lt;OtherControl AutomationProperties.LabeledBy=\u201d{Binding ElementName=textThingLabel}\u201d \/>\r\n<\/pre>\n<p><\/code><br \/>\nAnyway, that suffices for the basics of MSAA\/UIA support for WPF if you&#8217;re writing .Net Windows applications. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A technical note today for programmers. Screenreaders (blind users) interact with Windows programs through accessibility APIs. The most modern is UI Automation. But the first, and possibly most important still, is MSAA, Microsoft Active Accessibility. Windows will supply information from one interface to the other system if required, so most of the time you shouldn\u2019t &hellip; <a href=\"https:\/\/www.webbie.org.uk\/blog\/msaa-uia-and-wpf\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MSAA, UIA and WPF&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[50,36,32,51],"class_list":["post-283","post","type-post","status-publish","format-standard","hentry","category-microsoft","tag-msaa","tag-programming","tag-software","tag-uia"],"_links":{"self":[{"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/comments?post=283"}],"version-history":[{"count":5,"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/posts\/283\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/media?parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/categories?post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webbie.org.uk\/blog\/wp-json\/wp\/v2\/tags?post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}