title: Access Datagrid row on TemplateColumn button click
body: <p>I am implementing a file upload tool using Silverlight. In this I can browse for files and when I select a file then it is bound to a datagrid. In the datagrid I have a template column with a button to delete the particular item from the datagrid and ItemSource of the datagrid which is a <code>List&lt;&gt;</code>.</p>
  
  <p>I have a class UploadedFiles as below.</p>
  
  <pre><code>public class UploadedFiles
  {
      public FileInfo FileInf{get;set;}
      public int UniqueID{get;set;}
      public string FileName{get;set;}
      public string FileExtension{get;set;}
      public long FileSize{get;set;}
  }
  </code></pre>
  
  <p>I am using a datagrid with a templatecolumn like below with ItemSource set as <code>List&lt;UploadedFiles&gt;</code></p>
  
  <pre><code>&lt;data:DataGridTemplateColumn Width="100"&gt;
    &lt;data:DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataTemplate&gt;
        &lt;Button Click="btn_Click" Content="Del" Width="45"/&gt;
      &lt;/DataTemplate&gt;
     &lt;/data:DataGridTemplateColumn.CellTemplate&gt;
    &lt;/data:DataGridTemplateColumn&gt;
  </code></pre>
  
  <p>and the button click event handler is </p>
  
  <pre><code>private void btn_Click(object sender, System.Windows.RoutedEventArgs e)
  {
      /* I need to access the particular list item based on the datagrid
         row in which the clicked button resides.*/
  }
  </code></pre>
  
  <p>I need to access the particular list item based on the datagrid row in which the clicked button resides and remove the item from the <code>List&lt;UploadedFiles&gt;</code> and rebind the datagrid.</p>
  
  <p>Thanks</p>