title: Visual Studio Package - Include and use external resources (Images) over the code
body: <p>I am currently working on a visual studio package project in C#, that provides a new tool window to store and copy custom code snippets. </p>
  
  <p>So far, I designed the little window as follow:</p>
  
  <p><img src="https://i.stack.imgur.com/lxdai.png" alt="Overview about the graphical design"></p>
  
  <p>The XAML code for the window is:</p>
  
  <pre><code>&lt;TreeView Name="tevTemplates" Background="#00000000"&gt;
      &lt;TreeView.ItemTemplate&gt;
          &lt;HierarchicalDataTemplate ItemsSource="{Binding Items}"&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;Image Margin="0,0,5,0" Source="{Binding Image}" /&gt;
                  &lt;TextBlock Text="{Binding Title}" /&gt;
              &lt;/StackPanel&gt;
          &lt;/HierarchicalDataTemplate&gt;
      &lt;/TreeView.ItemTemplate&gt;
  &lt;/TreeView&gt;
  </code></pre>
  
  <p>And the custom data model I use:</p>
  
  <pre><code>using System.Collections.Generic;
  using System.Collections.ObjectModel;
  using System.Drawing;
  
  namespace Sago.TemQWindow.Classes
  {
      /// &lt;summary&gt;
      /// Represents a simple data item to display easy an item inside a view
      /// &lt;/summary&gt;
      public class MenuNode
      {
          /// &lt;summary&gt;
          /// Initializes a new instance of a Sago.TemQWindow.Classes.MenuNode object with the display title
          /// &lt;/summary&gt;
          /// &lt;param name="title"&gt;&lt;/param&gt;
          public MenuNode(string title) : this(title, null) { }
  
          /// &lt;summary&gt;
          /// Initializes a new instance of a Sago.TemQWindow.Classes.MenuNode object with the display title and image
          /// &lt;/summary&gt;
          /// &lt;param name="title"&gt;&lt;/param&gt;
          /// &lt;param name="image"&gt;&lt;/param&gt;
          public MenuNode(string title, Image image)
          {
              this.Items = new ObservableCollection&lt;MenuNode&gt;();
              Title = title;
              Image = image;
          }
  
          /// &lt;summary&gt;
          /// Gets or sets the display title
          /// &lt;/summary&gt;
          public string Title { get; set; }
  
          /// &lt;summary&gt;
          /// Gets or sets the display image
          /// &lt;/summary&gt;
          public Image Image { get; set; }
  
          /// &lt;summary&gt;
          /// Gets or sets the sub items of the node
          /// &lt;/summary&gt;
          public ObservableCollection&lt;MenuNode&gt; Items { get; set; }
      }
  }
  </code></pre>
  
  <p>After opening the tool window the following source code loads the content and sub directory contents of the template folder:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Loads the whole folder structure of the given path recursive
  /// &lt;/summary&gt;
  private void LoadStructure(MenuNode rootNode, string path)
  {
      // Gets all files
      string[] files = IO.Directory.GetFiles(path);
      foreach (string file in files)
      {
          // Creates and adds the sub node for all files inside the given folder
          string clearName = IO.Path.GetFileNameWithoutExtension(file);
          MenuNode node = new MenuNode(clearName);
          rootNode.Items.Add(node);
      }
      // Gets all sub directories
      string[] directories = IO.Directory.GetDirectories(path);
      foreach (string directory in directories)
      {
          // Creates and adds the sub directory as a sub node
          string clearName = IO.Path.GetFileNameWithoutExtension(directory);
          MenuNode node = new MenuNode(clearName);
          rootNode.Items.Add(node);
  
          // Calls the method recursive
          LoadStructure(node, directory);
      }
  }
  </code></pre>
  
  <p>In the next step, I want to visualize the folders and files within the treeview control with the specific images. As you can see, I already implemented the image propety inside the data model and XAML binding. </p>
  
  <p>Now the problem is that I don't know, how I add these images to the project and access them over the code. As i already researched the visual studio package project don't have the possibility to access to the Properties.Resources content.</p>
  
  <p>I would be very grateful if someone could help me with this problem.</p>