title: WPF DataGrid, How to bind property on custom DataGridColumn
body: <p>I have a WPF DataGrid like this :</p>
  
  <pre><code>&lt;DataGrid x:Name="dtgAgent"
            ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window, AncestorLevel=1}, Path=DataContext.AgentList}"
                            AutoGenerateColumns="False"&gt;
            &lt;DataGrid.Columns&gt;
                &lt;DataGridTextColumn Header="Agent Name" MaxWidth="140" MinWidth="80" SortDirection="Ascending" Width="100" CanUserReorder="False" IsReadOnly="True" Binding="{Binding Path=AgentName}"/&gt;
                &lt;DataGridTextColumn Header="Status"  Binding="{Binding Path=Status}" MinWidth="60"/&gt;
                &lt;DataGridCheckBoxColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" Header="Use" MaxWidth="40" MinWidth="40" Binding="{Binding Path=Used}" /&gt;
                &lt;DataGridTemplateColumn CellTemplate="{StaticResource sliderTemplate}" CanUserReorder="False" CanUserResize="False" Width="140" Header="Work Balance (%)"/&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>It's <code>ItemSource</code>property is bound to a <code>List</code> of Agent in my DataContext, here is the code of the Agent class :</p>
  
  <pre><code>public class Agent
  {
      public String AgentName { get;set; }
      public String Status { get; set; }
      public Boolean Used { get; set; }
      public Int16 WorkBalance { get; set; }
  
      public Agent(String AgentName)
      {
          this.AgentName = AgentName;
          Status = "Online";
          Used = true;
          WorkBalance = 50;
      }
  }
  </code></pre>
  
  <p>Each property of this class is bound to a column of my DataGrid. I'm experiencing trouble with the binding of <code>WorkBalance</code>property which is bound to a custom column, here is my column template : </p>
  
  <pre><code>&lt;DataTemplate x:Key="sliderTemplate"&gt;
      &lt;Grid&gt;
                  &lt;Slider HorizontalAlignment="Stretch" Minimum="0" Maximum="100" 
                          Value="{Binding Path=ItemSource.WorkBalance,RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/&gt;
      &lt;/Grid&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>I can't figure out how to bind the <code>Value</code>property of my Slider to the <code>WorkBalance</code>property of my list. Any suggestions ? </p>