This repository has been archived by the owner on May 1, 2024. It is now read-only.
In Xamarin.Forms.UWP, Unable to set Automation ID to custom control, if not used SetNativeControl() method #14228
Unanswered
Eswaran17392
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I am creating a custom control in Xamarin.Forms which is inherited from TemplatedView and using the application in all three platforms. For testing purposes, I need to set Automation ID for all native controls.
Usually, by using AutomationPeer we can set Automation ID to native UWP control from the UWP renderer project. But, in my custom control, I get this. Control is null always.
So, I can’t set Automation ID in UWP renderer class as Forms TemplatedView is a FrameworkElement in UWP.
My query is,
How to get a native element (this.Control) in the UWP renderer project for Xamarin.Forms TemplatedView.
How to set Automation Id to native UWP control if this.Control is null.
Expected Behavior
Set Automation ID to custom control
Actual Behavior
Since this.Control is null, Unable to set Automation ID to custom control
The code snippet is provided below:
`
class FormsCustomLayout : TemplatedView
`
The custom renderer code snippet is provided below:
`
class FormsCustomLayoutRenderer : ViewRenderer<FormsCustomLayout, FrameworkElement>
`
Please get the sample from the below link: Custom Sample
Beta Was this translation helpful? Give feedback.
All reactions