title: List of text blocks in wpf
body: <p>I'm have collections of books and ListVew for representation books data. I'm try to make list of text blocks. Each text block need to convert data with convertor which take one model and give one string with data, but i don't know how to bind collections and pass one model to convertor.</p>
  
  <p>Book model:</p>
  
  <pre><code>namespace Books.Models
  {
      public class Book : IModel
      {
          public Book()
          {
              Authors = new List&lt;Author&gt;();
              Tags = new List&lt;string&gt;();
          }
          public string Name { get; set; }
          public List&lt;Author&gt; Authors { get; set; }
          public string ISBN { get; set; }
          public int Pages { get; set; }
          public List&lt;string&gt; Tags { get; set; }
          public int PublicationYear { get; set; }
          public House House { get; set; }
      }
  }
  </code></pre>
  
  <p>Books collection:</p>
  
  <pre><code>namespace Books.Collections
  {
      public class ModelsCollection : Dictionary&lt;string, IModel&gt;
      {
          public void Add(IModel model)
          {
              Add(model.Name, model);
          }
          public IEnumerable&lt;IModel&gt; GetAll()
          {
              foreach (IModel model in Values)
                  yield return model;   
          }
      }
  }
  </code></pre>
  
  <p>Convertor:</p>
  
  <pre><code>namespace Books
  {
  
      [ValueConversion(typeof(ModelsCollection), typeof(string))]
      public class BooksConvertor : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              Book book = (Book)value;
              return book.Name + " - " + string.Join(", ", book.Authors.Select(x =&gt; x.Name));
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }
  }
  </code></pre>
  
  <p>ListView in XAML</p>
  
  <pre><code>    &lt;ListView &gt;
          &lt;TextBlock Text="{Binding Path=Book,Converter={StaticResource BooksConvertor}}"/&gt;
      &lt;/ListView&gt;
  </code></pre>