Forum General

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to pass Func<AppQuery, AppQuery> as AppQuery for another Func<AppQuery, AppQuery>?

ohiliohili Member
edited March 2020 in General

Hello everyone.

I have a list of variables, that look at some text controls, like:

Func<AppQuery, AppQuery> MyField = c => c.Marked("MyField");

I need to find a text inside this element. Currently the only option I know is to do this:

// Create another variable and use it
string MyFieldText(string textToMatch)
{
   return app.Query(c => c.Marked("MyField").Descendant().Text(textToSearch);
}

The problem is that I need to create another variable for every element. Is there a simple way of reusing MyField. Something like this:

app.Query(MyField.Descendant().Text(textIAmLookingFor));

But this doesn't work, because MyField is Func<AppQuery, AppQuery>, not AppQuery...

Answers

Sign In or Register to comment.