WPF Datagrid Accessibility

Aug 9, 2009 at 9:11 PM

Hi,

 

I am a blind computer programmer trying out the new datagrid from the wpf toolkit. Is there a way to set the text of the buttons on the datagrid such as add, update, delete, select all, etc. ? I am unable to find any way to add text to a button on the grid. While at runtime, I can use my screen reader to investigate the rendered datagrid and can see that there are buttons using my screen reader spoken to me as "button graphic xxxx". I'd like to change the caption/text of the buttons to be actual text, not just graphics,  so the buttons can be spoken to me. Hopefully I do not need to make template columns to accomplish this and there are actual properties in the datagrid that lets a programmer change the caption of the default datagrid buttons?

 

Also, is there a way to tab to the data brid buttons to activate them?

 

Finally, are there any built in keyboard shortcuts for add a new row/record? I found f2 for edit and the delete key for deleting a row but cannot find a keystroke to add a new blank row to the datagrid where I can tab through each item in a new blank row and key in the data to add it to the datagrid.

 

Thanks!

 

/Justin

Coordinator
Aug 11, 2009 at 9:42 PM
Edited Aug 11, 2009 at 9:45 PM

Hi Justin,

Could you supply a little more information for us?  We tried this out using the Windows 7 screen reader today and weren't seeing the same results you described, so we just want to make sure that we understand the problem and the desired resolution so that we can come up with a recommendation.  A few questions we have:

1. Which screen reader are you using?  We didn't find that the built in Win7 one read much of anything useful from our DataGrid, so we were wondering if maybe you were using a different application.

2. You mention buttons for Add, Delete, Update, and Select All.  Are these buttons that you've added to your application?  The reason I ask is that DataGrid does not have built-in UI for most of these operations.  Select All does have a button, but it's just the blank header in the upper left corner and does not have any graphics or text built in to it.  Deleting rows can be accomplished programmatically or with keyboard shortcuts, but we don't have any buttons on the DataGrid to invoke this operations.  Adding new rows or Updating can be accomplished programmatically, but I don't believe we have any shortcuts for those either.

3. Can you explain what you would envision as the best case for how a screen reader would read the DataGrid?  For example, should it announce each UI element and then its data, or should it just read the data, etc.?  For example, if you had a DataGrid with 3 columns for First, Middle, and Last name information and two items which had content "John Michael Doe" and "Jane Marie Doe", is "Row 1, Column First Name: John, Column Middle Name: Michael, Column Last Name: Doe.  Row 2, Column First Name: Jane, Column Middle Name: Marie, Column Last Name: Doe" the desired output or would something like "DataGrid with columns First Name, Last Name, Middle Name.  Row 1, John Michael Doe.  Row 2, Jane Marie Doe," be better?  What should it say if, for example, it comes across the header which is enabled to Select All, or a blank "AddNewRow" at the bottom of the grid where you can enter data?  We just want to make sure that we understand how you are expecting the DataGrid to work, and if it's not meeting those expectations, how we can fix it.

You should be able to add buttons to your application which are hooked up to DataGrid's events to invoke things like making the blank new row appear or selecting all or deleting the selected rows, and you should be able to tab to these buttons.  We do not have a shortcut key for adding a new row, unfortunately, but you should be able to add one by handling the KeyDown event. 

Thanks!
Samantha

Aug 11, 2009 at 11:42 PM
Hi Samantha,
Sorry, my mistake, I thought the datagrid had built in buttons for add/update/delete on the datagrid itself so please disregard that misconception.
About the screen reader, I'm just programming using the built in narrarator.
The best case scenario is that the screen reader should it announce each UI element and then its data.
For example: "Row 1, Column First Name: John, Column Middle Name: Michael, Column Last Name: Doe. Row 2, Column First Name: Jane, Column Middle Name: Marie, Column Last Name: Doe".
While I have your ear, is there any property on the datagrid itself that I can use to tell if it is in read only mode or edit mode?
Thanks!

Regards,
Justin

Coordinator
Aug 13, 2009 at 6:23 PM

Hi Justin,

Yup, there are a couple different ways you can tell if DataGrid is in edit mode or not.  On DataGrid, if you listen for the BeginningEdit event - it will tell you when the DataGrid is about to be put into edit mode.  Also, both DataGridRow and DataGridCell have a boolean IsEditing property, so you can also listen for changed in that property.

Thanks!
Samantha

Aug 13, 2009 at 6:47 PM
Hi Samantha,
Thanks for the reply.
How can I detect if the datagrid is in read only or edit mode by using UI automation?

Regards,
Justin

Coordinator
Aug 13, 2009 at 8:45 PM

Hi Justin,

Unfortunately, "Editable" is not one of the supported properties of Automation.  As an ugly workaround, you can try and invoke a DataGridCellItemAutomationPeer - if DataGrid is readonly, the operation will fail and you'll get an InvalidOperationException.


Thanks,
Samantha

Aug 14, 2009 at 2:26 AM
HI Samantha,
How would I invoke this from UIA? All I have is a IRawElementProviderSimple instance.
Thanks for any clarification!

Regards,
Justin

Coordinator
Aug 25, 2009 at 7:23 PM

Justin,

Using GridPattern supported by Datagrid you can retrieve a DataGridCell using GetItem method. DataGridCell element's corresponding AutomationPeer supports IValueProvider and IInvokeProvider. You can check IValueProvider.IsReadOnly property or try IInvokeProvider.Invoke method.

http://msdn.microsoft.com/en-us/library/ms747211.aspx has code for using InvokePattern.

 

-Keerthi

Aug 26, 2009 at 11:58 AM
Hi Keerthi,
Thank you for the reply.
How do I get at the edit control embedded in a cell via UIA to obtain its text provider interface?
I am using a sample datagrid that is editable. However, the editable cells do not contain any edit control, just static text which do not have a text provider pattern implemented.
Thanks for any help!

Regards,
Justin
----- Original Message -----
From: [email removed]
To: [email removed]
Sent: Tuesday, August 25, 2009 3:31 PM
Subject: Re: WPF Datagrid Accessibility [wpf:64987]

From: kedecond

Justin,

Using GridPattern supported by Datagrid you can retrieve a DataGridCell using GetItem method. DataGridCell element's corresponding AutomationPeer supports IValueProvider and IInvokeProvider. You can check IValueProvider.IsReadOnly property or try IInvokeProvider.Invoke method.

http://msdn.microsoft.com/en-us/library/ms747211.aspx has code for using InvokePattern.

-Keerthi