We have a WPF project, at some point we want to display a list of compatibles devices. Thoses devices comes from a registry in which different modules(projects) can add their library.
At the end, I'm trying to bind a string with the image to the Source of an an image:
<Image Source="{Binding Image}"></Image>
Currently in "Image", I've this:
"/My.Project.Name;Component/Images/SomeImage.png"
Please note that :
- "Images" is a folder in the mentionned project
- "My.Project.Name" is only a library project, so it's not the WPF one
- "SomeImage.png" is currently set as "Content".
It's what I found I should use, but currently I get this error:
System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value '/My.Project.Name;Component/Images/SomeImage.png' (type 'String'); fallback value will be used, if available. BindingExpression:Path=Image; DataItem='WizardOneChoice`1' (HashCode=56913160); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource') IOException:'System.IO.IOException: Cannot locate resource 'images/someimage.png'.
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.get_ContentType()
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& 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.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
at MS.Internal.Data.TargetDefaultValueConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'
What am I missing?