How to get automation id of Xamarin.Forms listview in renderer ?
Xamarin.Forms ListView can be automated in application level by setting AutomationId in xaml page. You can get automation ID in each platform by rendering listview as shown in the following code sample.
Xaml
<ContentPage> <ContentPage.Content> <StackLayout> <listview:SfListView x:Name="listView" AutomationId="12345"/> </StackLayout> <ContentPage.Content> </ContentPage>
You can use the OnElementChanged override method to get Automation ID in all three platforms.
C#
protected override void OnElementChanged(ElementChangedEventArgs<SfListView> e)
{
base.OnElementChanged(e);
object automationId = this.Element.AutomationId;
System.Diagnostics.Debug.WriteLine("UWP Renderer Automation ID" + automationId);
}
Sample link: Get AutomationId In Renderer