title: WPF window with user control throwing exception in XAML designer
body: <p>I have a WPF window which contains a user control.  The user control contains an image which is bound to a boolean property through the use of a value converter that looks like this:</p>
  
  <pre><code>class BooleanStatusToImageConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              if ((bool)value == true)
              {
                  return new BitmapImage(new Uri("pack://application:,,,/Resources/green_orb_24x24.png", UriKind.Absolute));
              }
              else
              {
                  return new BitmapImage(new Uri("pack://application:,,,/Resources/red_orb_24x24.png", UriKind.Absolute));
              }
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }
  </code></pre>
  
  <p>When I run my application, everything seems to be working properly.  However, when I view my window in the XAML designer, I get an IOException (from the user control) which indicates that it can't find resources/red_orb_24x24.png (the image URI returned from the value converter when the boolean property is false).  The stack trace from the exception looks like this:</p>
  
  <pre><code>at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
  at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
  at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
  at System.IO.Packaging.PackWebResponse.GetResponseStream()
  at System.IO.Packaging.PackWebResponse.get_ContentType()
  at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid&amp; clsId, Boolean&amp; isOriginalWritable, Stream&amp; uriStream, UnmanagedMemoryStream&amp; unmanagedMemoryStream, SafeFileHandle&amp; safeFilehandle)
  at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
  at System.Windows.Media.Imaging.BitmapImage.FinalizeCreation()
  at System.Windows.Media.Imaging.BitmapImage.EndInit()
  at System.Windows.Media.Imaging.BitmapImage..ctor(Uri uriSource, RequestCachePolicy uriCachePolicy)
  at System.Windows.Media.Imaging.BitmapImage..ctor(Uri uriSource)
  at MyTestApplcation.BooleanStatusToImageConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
  at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
  at System.Windows.Data.BindingExpression.Activate(Object item)
  at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
  at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
  at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
  at MS.Internal.Data.DataBindEngine.Run(Object arg)
  at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
  at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
  at System.Windows.ContextLayoutManager.UpdateLayout()
  at System.Windows.UIElement.UpdateLayout()
  </code></pre>
  
  <p>I'm guessing that this may be related to my URI and the fact that the user control is nested inside the window but that's just a guess on my part.  Has anyone seen something like this before?</p>