Hi All,
I want to get Grid by AutomationId, but failed.
Wpf Xaml:
<Window x:Class="AutoApp.MainWindow" AutomationProperties.AutomationId="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"><Grid AutomationProperties.AutomationId="MainGrid" IsEnabled="True" Focusable="True" Visibility="Visible" > </Grid></Window>
I want to get the Grid by AutomationId, here is my code:
AutomationElement Desktop = AutomationElement.RootElement; var window = Desktop.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "MainWindow")) var Grid = window.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "MainGrid"))
I can get the window, but i can't get Grid in row 3th ?
Anyone can help me, Thank you !
Yuanzhi.Tang