I want to create a list of RadioElement via the values of an ArrayList.
Imagine I have a list:
System.Collections.Generic.List<MyClass> mylist
Now I don't want to iterate through all elements and create a RadioElement for everyone. Is it possible to create the RadioElements automatically by a property of MyClass, by passing the List<MyClass>.
And how can I get the Tapped Event when the user selects one of the RadioElements?
Linq to the rescue: https://msdn.microsoft.com/en-us/library/bb397900.aspx
As an example, I created a MyClass with a bool property
CreateRadioElementand anElementTextstring property:Then I created a List of MyClass objects:
So now we only want the MyClass objects with
CreateRadioElementset to true:Now you execute the query with a foreach loop:
And you will only see 1, 3, and 5 in the console output. And of course instead of writing to the console, you could assign each to RadioElement.