I thought it would be a great to be able to generate automated ids based on x:Name values, which could be set in custom controls.
However I've not be able to find a way to retrieve the x:Name in code.
Just for clarity I'm using our CustomButton and CustomLabel controls for all buttons and labels etc.
Here is for example a button set in XAML file:
<Button x:Name="MyButton" Text="Click here" />
And then, you can read "x:Name" attribute in code behind:
MyButton.AutomationId = nameof(MyButton);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.