This project is read-only.

White Unable to identify textbox within a Editable Datagrid

Jul 8, 2011 at 6:59 AM

Hi Guys

I have been using white for automating wpf quite a long time and so far its very good.

I got into a problem with the editable data grid that was developed recently.

The DataGridCell is a "TextBlock" control until the user double clicks on it to enable editing.

When double clicked, the "editbox" is rendered and is available for the user to edit. After edit, change in focus by tab 'ng out or pressing enter will change the cell back to TextBlock.

Problem 1: Unable to double click on TextBlock to enable editing. UIItem cannot receive focus exception is received. Workaround is to use attached mouse.

Problem 2: Once enabled, edit box is visible and user can set value and change the focus. But, any attempts to edit another cell value fails, because the edit box is not visible in the UI tree anymore. I have to close the application and reopen it to do it. 

Has anyone experienced this kind of issues before? Any solution or suggestion is much appreciated.

Jul 11, 2011 at 6:41 PM

I have just found this to be true of Editable Grids as well when even bypassing White and using the Windows Automation like this (where controlCondition is of type Textbox):

oGrid.AutomationElement.FindAll(TreeScope.Descendants, gControl.cellCondition)[0].FindAll(TreeScope.Descendants, gControl.controlCondition)[0].GetRuntimeId();

So far Ihave been unable to find a solution...


Jul 12, 2011 at 6:05 AM

An update on this issue.

I have managed to overcome the problem 1, by doing a DataGridCell.DoubleClick() rather than doing a double click on Textblock.

Then I used AttachedKeyboard to clear the existing values, enter new values and press Enter/Tab out to commit the changes. This is working perfectly.

Now to verify, the new value is a problem because,as mentioned before, TextBlock element is not exposing the value. A refresh of the datagrid is required to get the new value.

My Question is, Is it possible to refresh the datagrid using ListViewEvents or by any other means?

Jul 12, 2011 at 12:37 PM

>> I got into a problem with the editable data grid that was developed recently.

By recently do you mean .NET 4?

Jul 13, 2011 at 1:53 AM
Edited Jul 13, 2011 at 1:55 AM

Hi Vivek,

No, we are still using .Net 3.5. However, we made further progress yesterday.

Our developers implemented AutomationPeerClass for the DatagridCell and exposed the value of the TextBlock through Datagridcell - value pattern.

SetValue in the textbox is still having issues, but I'm using following piece of code to do that.

ListViewCell cell = new ListViewCell(aeCell, new NullActionListener());

AttachedKeyboard kb = w.Keyboard;

// Clear existing value using Keyboard : SendKeys


// send keys - value

// Press enter to change focus

This works perfectly and is reliable. AutomationPeerClass for the DatagridCell also exposes IsReadOnly property which helps when the editbox is disabled in certain cases.

Jul 18, 2011 at 5:05 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jul 28, 2013 at 1:29 PM
Please report the issue on GitHub ( if it is still an issue. Issues raised on CodePlex will not be fixed.
Also include the version of TestStack.White you are using.