Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Accessibility test application: Screenreader does not read ListItem contents in DataBindingDemo #307

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

ryalanms
Copy link
Member

Guy Barker's fix for Accessibility Bug 1144842: A11y_.NETCore_DatabindingDemo_List of Products_Screenreader: Screenreader does not read the text content written on the list present (Elecronics,Sports and Books)

…dingDemo_List of Products_Screenreader: Screenreader does not read the text content written on the list present (Elecronics,Sports and Books)
@rladuca
Copy link
Member

rladuca commented Aug 19, 2020

This is a strange one. I have some issue with just using the name, when there is something like checked/unchecked available assuming the correct UIA representation of the star itself. However, there is no real way of changing checked/unchecked w.r.t. to narrator to say something like "starred" or "featured", so this is probably the best compromise. Better would be some way of configuring the text relayed from something implementing the TogglePattern. obviously beyond the scope of this.

@vatsan-madhavan vatsan-madhavan merged commit c6321b2 into microsoft:master Aug 19, 2020
// use of the star however in the visuals is important, as is all the
// text shown in the item. These data can be exposed programmatically
// through the UI Automation (UIA) Name property of the item by returning
// the desired string in ToString() here. That string will typically be
Copy link
Contributor

@SamBent SamBent Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use ToString for this. It breaks MVVM (by putting View information in the Model), and doesn't work in general. For instance if the app had another view of an AuctionItem, or if the AuctionItem class wasn't owned by the app, you couldn't do this.

Instead set the Name property in the View, matching the visual described by that view as appropriate. The mechanics to do this: 1) declare (or add to an existing) ItemContainerStyle for the ListBox, 2) set the AutomationProperties.Name attached property in that style, 3) use data-binding to make the name depend on the data item, 4) use multi-binding if the name depends on several properties, and a converter to piece them all together.

Sketch:

<ListBox.ItemContainerStyle>
  <Style TargetType="ListBoxItem">
     <Setter Property="AutomationProperties.Name">
         <Setter.Value>
             <MultiBinding Converter="{StaticResource.MyConverter}">
                <Binding Path="SpecialFeatures"/>
                <Binding Path="Description"/>
                <Binding Path="CurrentPrice"/>
 ///>

MyConverter.Convert(object[] values, ...)
{
   SpecialFeatures specialFeatures = ...convert values[0] to SpecialFeatures...;
   string description = values[1] as string;
   double currentPrice = values[2] as double;
   return   ... Guy's code ... ;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants