I'm trying to attach an automationId to items within a listview. Ideally by binding a project name to the item that is shown.
<ListView
ItemsSource="{Binding Projects}"
AutomationId="{Binding Projects}
HasUnevenRows="True"
IsPullToRefreshEnabled="true"
CachingStrategy="RecycleElement"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
The code is deploying but not running when I get to the page, has anyone found a good workaround to bind the ID like that?
Long term, I want to use it with the Xamarin Forms ability to scroll which can scroll to a marked item, but not scroll to a displayed text.
AutomationId
is not a bindable property as apparent in the Xamarin.Forms source code:
Xamarin.Forms.Core.Element.cs
string _automationId;
public string AutomationId
{
get { return _automationId; }
set
{
if (_automationId != null)
throw new InvalidOperationException("AutomationId may only be set one time");
_automationId = value;
}
}
This has been raised by several people on Xamarins User Voice.
You'll need to hard code the AutomationId
for the meantime and build your UI tests with a hard coded id in mind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With