title: How can I bind a control into a WPF listview column
body: <p>I'm new to WPF so forgive me if I've missed something obvious</p>
  
  <p>I have the following list view control (non relevent details removed for brevity)</p>
  
  <pre><code>&lt;ListView&gt;
    &lt;ListView.View&gt;
      &lt;GridView&gt;
        &lt;GridViewColumn Header="Type" DisplayMemberBinding="{Binding Type}"/&gt;
        &lt;GridViewColumn Header="Details" DisplayMemberBinding="{Binding Details}"/&gt;
      &lt;/GridView&gt;
    &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>I add items to this list view in code behind</p>
  
  <pre><code>public void Add(LogEntry entry)
  {
    ListViewItem item = new ListViewItem();
    item.Content = entry;
    listView.Items.Add(item);
  }
  </code></pre>
  
  <p>where LogEntry has public string properties for "Type" and "Details"</p>
  
  <p>So far, so good, all works lovely but..
  I want my details property to be an element itself (TextBox or DockPanel containing various types of content)
  How can I bind this Element to the list column?</p>
  
  <p>Using the code above, Changing "Details" to an element I simply get the class name in the list box (e.g. System.Windows.Control.TextBox) as by default the cell displays the ToString() value of the property.
  I have googled examples which use a DataTemplate but I can't find an example of binding an element to the content of a panel.
  The control cannot be defined in xaml as its structure and contents are not known until runtime</p>
  
  <p>The binding is one way (I only need to display the list, not update the underlying data structure)</p>
  
  <p>To make my problem clearer, I want to bind the following list item</p>
  
  <pre><code>class LogEntry
  {
    public string Type {get;}
    public DockPanel Details {get;} // This dock panel was created by code and contains
                                    // various elements not predictable at compile time
  }
  </code></pre>