There is an extension method:
static public List<TResult> ToList<TResult>(this UIElementCollection c, TResult result) where TResult : class { var l = new List<TResult>(); foreach (var item in c) { l.Add((TResult)item); } return l; } But the problem appears when I call:
var l = stack.Children.ToList(CheckBox); stack is StackPanel . where all its elements are CheckBox .
Writes that CheckBox type, which is not valid in this context.
How to implement correctly?