We have a new WPF web application which genearates a lot of dynamic controls. One of them is a "TextBlock".
I used the UISpy to see the control properties. I was able to see the control only in the Raw tree and not in Contol tree view.
I tried using the below code to get the control
AutomationElement parent; //Initialized parent element.
AutomationElementCollection coll = parent.FindAll(TreeScope.Descendants, Automation.RawViewCondition);
coll had 0 elements in it.
Then I used the TreeWalker to see if I can get the control, using the below code and I was able to get it.
TreeWalker walker = new TreeWalker(Automation.RawViewCondition);
AutomationElement e = walker.GetFirstChild(parent);
while(e != null)
{
e = walker.GetNextSibiling(e);
}
The only property that looks a bit suspisious to me about this control is its AutomationElement property ¡°IsControlElement¡± is false.
So my question is, why can't I get the control using FindAll/FindFirst method when I am mentioning it to use the raw view. Is there something wrong I am doing that is making the IsControlElement property of my TextBlock false
Smitha Saligrama MSFT