Got a variable called UiList: A list witch contains several UI elements
Got another variable called Label: This variable is a string witch contains the aaname property of the ui element
I need to use a query to select/find/get the ui element witch aaname property is equal to the label variable
I’m trying to build something like: UiList.Cast(Of UiElement).Contains(Label) but this obviously does not work.
Hello,
Why did you try to cast your list if you said that it is a list of Ui Elements already?
You can do this directly in a LINQ query, without having to iterate through the list of UI elements:
UiList.AsEnumerable.Select(function (x) Label.Contains(x.Get(“aaname”))).ToList()
I though this was the solution but it returns error:
error BC30518: Overload resolution failed because no accessible ‘FirstOrDefault’ can be called with these arguments:
Extension method ‘Public Function FirstOrDefault(defaultValue As UiElement) As UiElement’ defined in ‘Enumerable’: Lambda expression cannot be converted to ‘UiElement’ because ‘UiElement’ is not a delegate type.
This one returned error too. But I didnt though it would work for me since I want to return a unique UiElement from the List of UiElements and you end the query with *.ToList()
Thank you, this works but is not what Im looking for.
I mean I have no problem doing a for each of the list of uielements and checking if aaname equals to the variable label and then use a breack if I get a match.
I’m trying to find a more optimal way of retrieve that Ui Element.