title: WPF - Dynamically instantiating a ViewModel for an item in the Collection
body: <p>I have two models - one the 'Field' and other, the 'Layout' which in turn is a collection of Field. I use these to implement a tree structure. I am trying to avoid implementing a ViewModel for the Layout simply to avoid having to navigate to each node on the tree and to avoid another indirection for pushing background updates. But I have to create a ViewModel for the items (Field) in the collection. Is that possible without breaking the MVVM pattern?</p>
  
  <p>I was actually thinking of something like an extension properties on the 'Field' which I can use for binding in the View but after a bit of analysis found <a href="http://blogs.msdn.com/b/ericlippert/archive/2009/10/05/why-no-extension-properties.aspx" rel="nofollow">that is not possible</a>. Is there any other technique that could be used in this scenario?</p>
  
  <pre><code>// Model
  public interface IField
  {
      string Name { get; set; }
      string Type { get; set; }
  }
  
  public interface ILayout : ICollection&lt;IField&gt;, IField
  {
  }
  </code></pre>