title: how to get absolute path of a selected item on listview on mouse double click
body: <p>I am adding some files to the listview. I want to get absolute path of an item in a listview on mouse double click. Below is the code and xaml I am using to retrieve items and add them to listview</p>
  
  <p>Code:</p>
  
  <pre><code>public class Documents
  {
      public string Name
      {
          get;
          set;
      }
  
      public ImageSource Image
      {
          get;
          set;
      }
  }
  
  //Code to retrieve documents
  
          String docpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
          string[] docnames = System.IO.Directory.GetFiles(docpath);
  
          foreach (string docname1 in docnames)
          {                
              System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(docname1);
              string docname = Regex.Match(docname1, @".*\\([^\\]+$)").Groups[1].Value;
  
              System.Windows.Controls.Image image = new System.Windows.Controls.Image();
  
              int fileExtPos = docname.LastIndexOf(".");
              if (fileExtPos &gt;= 0)
                  docname = docname.Substring(0, fileExtPos);
  
              FileInfo fileExt;
              fileExt = new FileInfo(docname1);
              if (fileExt.Extension.ToLower() == ".doc" || fileExt.Extension.ToLower() == ".docx" || 
                  fileExt.Extension.ToLower() == ".xls" || fileExt.Extension.ToLower() == ".xlsx" || 
                  fileExt.Extension.ToLower() == ".txt" || fileExt.Extension.ToLower() == ".rtf" || 
                  fileExt.Extension.ToLower() == ".pdf" || fileExt.Extension.ToLower() == ".dot" || 
                  fileExt.Extension.ToLower() == ".html" || fileExt.Extension.ToLower() == ".odt" || 
                  fileExt.Extension.ToLower() == ".odm" || fileExt.Extension.ToLower() == ".ott" || 
                  fileExt.Extension.ToLower() == ".info" || fileExt.Extension.ToLower() == ".xml" || 
                  fileExt.Extension.ToLower() == ".xps" || fileExt.Extension.ToLower() == ".xhtml" || 
                  fileExt.Extension.ToLower() == ".omm" || fileExt.Extension.ToLower() == ".csv")
              {
  
                  files.Add(new Documents()
                  {
                      Name = docname,
                      Image = icon.ToImageSource()
                  });
              }
          }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;GroupBox Grid.Column="1" Header="My Documents" HorizontalAlignment="Left" Margin="10,0,0,10" Width="200"&gt;
          &lt;ListView x:Name="DocsListView" HorizontalAlignment="Left" Height="500" VerticalAlignment="Top" Width="175" Margin="5,5,5,5" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True" ItemsSource="{Binding docs, ElementName=MyWindow}" &gt;
              &lt;ListView.View&gt;
                  &lt;GridView&gt;
                      &lt;GridViewColumn Header="File" Width=" auto"&gt;
                          &lt;GridViewColumn.CellTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;Grid&gt;
                                      &lt;Image Source="{Binding Image}" /&gt;
                                  &lt;/Grid&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/GridViewColumn.CellTemplate&gt;
                      &lt;/GridViewColumn&gt;
                      &lt;GridViewColumn Header="Name" Width="auto" DisplayMemberBinding="{Binding Name}" /&gt;
                  &lt;/GridView&gt;
              &lt;/ListView.View&gt;
              &lt;ListView.ItemContainerStyle&gt;
                  &lt;Style TargetType="{x:Type ListViewItem}"&gt;
  
                      &lt;EventSetter Event="MouseDoubleClick" Handler="ListView_MouseDClick" /&gt;
  
                  &lt;/Style&gt;
              &lt;/ListView.ItemContainerStyle&gt;
          &lt;/ListView&gt;
      &lt;/GroupBox&gt;
  </code></pre>