LINQify ItemsControlRegion

Mar 26, 2008 at 4:53 AM
Instead of:

public IList<UIElement> Views
{
  get
  {
    List<UIElement> views = new List<UIElement>(WrappedControl.Items.Count);
    
    foreach (UIElement item in WrappedControl.Items)
    {
      views.Add(item);
    }
    
    return views;
  }

LINQified:
public IEnumerable<UIElement> Views
{
  get { return WrappedControl.Items.Cast<UIElement>(); }
}

The less code I review (especially code without any logic/value), the happier I am and the more interesting feedback I can provide.