title: IOException : cannot locate resource at Design time only
body: <p>I'm having a problem with my designer on a MVVM project.</p>
  
  <p>I have a <code>TreeView</code> with a custom <code>DataTemplate</code> :</p>
  
  <pre><code>                             &lt;DataTemplate&gt;
                                  &lt;StackPanel Orientation="Horizontal"&gt;
                                      &lt;Image Name="img"  Width="20" Height="20" Stretch="Fill" 
                                         Source="{Binding 
                                         RelativeSource={RelativeSource 
                                         Mode=FindAncestor, 
                                         AncestorType={x:Type TreeViewItem}}, 
                                         Path=Header, 
                                         Converter={StaticResource HeaderToImageConverter}}"       
                                         /&gt;
                                      &lt;TextBlock Text="{Binding}" Margin="5,0" /&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>Resource declaration :</p>
  
  <pre><code>&lt;Window x:Class="BlobWorld.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:Core="clr-namespace:BlobWorld;assembly=" 
          xmlns:helper="clr-namespace:BlobWorld.Helper"
          mc:Ignorable="d"
          Title="MainWindow" Height="350.459" Width="746.561"
          DataContext="{DynamicResource MainWindowViewModel}"&gt;
      &lt;Window.Resources&gt;
          &lt;helper:HeaderToImageConverter x:Key="HeaderToImageConverter"/&gt;
      &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>My Converter is :</p>
  
  <pre><code>public class HeaderToImageConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              if ((value as string).Contains(@"."))
              {
                  Uri uri = new Uri("pack://application:,,,/images/File.png");
                  BitmapImage source = new BitmapImage(uri);
                  return source;
              }
              else
              {
                  if (!(value as string).Contains(@":"))
                  {
                      Uri uri = new Uri("pack://application:,,,/images/folder.png");
                      BitmapImage source = new BitmapImage(uri);
                      return source;
                  }
                  else
                  {
                      Uri uri = new Uri("pack://application:,,,/images/diskdrive.png");
                      BitmapImage source = new BitmapImage(uri);
                      return source;
                  }
              }
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
          {
              throw new NotSupportedException("Cannot convert back");
          }
      }
  </code></pre>
  
  <p>It works perfectly at run-time, but when I'm using the xaml "design" windows in Visual Studio instead of seeing the appearance of my Windows, I only have a <code>IOException : Cannot locate resource 'images/folder.png'</code></p>
  
  <p>Where is my problem coming from ?
  How can I fix it ?</p>