Click here to Skip to main content
15,888,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I can not bind to the AutomationId property.
I need to add AutomationId property to a custom control that contains, among other controls, a textbox.
The custom control is instantiated in a list view so it is present in several Items.
In order to provide a unique AutomationId for the textbox I computed its value as a concatenation of the textbox name and the AutomationId property of the custom control instance it belongs to.
The custom control instance AutomationId is itself computed with a binding to the AutomationId of the ListViewItem where it is instantiated which includes the item index.

Snooping through the tree I can see that the AutomationId of the custom control is computed correctly but the AutomationId of the contained TextBox is not.
Debugging the binding using a converter I could see that the AutomationId property of the custom control is an empty string when it is used by the TextBox to compute its AutomationId.

How can i solve this problem?
Generally speaking, in cases where we have a dynamic control defined inside a custom control which is itself instantiated in a dynamic control, how to proceed with the automationId setting in the inner controls?
Thanks in advance,
Pietro
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900