views:

507

answers:

2

I have a Silverlight 2.0 application which binds a listbox to a collection of classes that contain a BitMap property (which are used for navigation). I've both included the images in the XAP as content and created the BitMap manually and set it as the controls source and I have also embedded the images as resources in the DLL and got the image from the manifestresourcestream and set the image. Both of these routes work great when the XAP is displayed using the Silverlight 2.0 plugin so I know my images are being deployed correctly. Unfortunately, when viewed on a machine with the Silverlight 3.0 plugin, neither of these methods display the images in the listbox.

Note that this problem only occurs when the binding takes place in an ItemTemplate of a Listbox. If I set the same property outside of the listbox it appears to find the images and work fine.

Any idea what has changed in ListBox binding between 2.0 and 3.0? I do have build 3.0.40307 of the Silverlight plugin on the machine I can reproduce the error on.

-Kevin

+1  A: 

Ok...a solution was found (thanks to some help on the Silverlight boards):

First, it only works with the full release of the Silverlight 3.0 plug-in. Which poses a strange problem (described below).

Second, I had to switch from binding directly to an Image or Bitmap class and instead use an Imagesource class (which can be easily instantiated with a Bitmap passed to the constructor). Simple enough... Don't know why this is required in SL 3.0 but not 2.0 but it broke my code. My code is still written and compiled against the 2.0 plug-in but just runs in the 3.0 plug-in on computers that have it.

Which brings me to the strange issue...I have VM's or desktops with SL 2.0, SL 3.0 (Beta), and SL 3.0 (Full Release) available for testing. My plug-in now works fine in SL 2.0 and SL 3.0 (Full Release) but not in SL 3.0 (Beta). I get no warning and it opens fine, just that my images do not bind. So my concern is that a number of developer/techy oriented people will have the beta of 3.0 which still runs 2.0 plug-ins as it's backward compatible. They aren't forced to upgrade for any reason to run my site.

If you have any of these environments available here is a link to the site in question: http://stlouisdayofdotnet.com/DayOfDotnet.html

Kevin Grossnicklaus
A: 

Error when setup databinding with image converter for listbox using datatemplate

at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.BitmapSource_SetSource(BitmapSource bitmapSource, CValue& byteStream) at System.Windows.Media.Imaging.BitmapSource.SetSourceInternal(Stream streamSource) at System.Windows.Media.Imaging.BitmapImage.SetSourceInternal(Stream streamSource) at System.Windows.Media.Imaging.BitmapSource.SetSource(Stream streamSource) at display_db_image.ImageConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) at System.Windows.Data.BindingExpression.ConvertToTarget(Object value) at System.Windows.Data.BindingExpression.GetValue(DependencyObject d, DependencyProperty dp) at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp) at System.Windows.Data.BindingExpression.RefreshExpression() at System.Windows.Data.BindingExpression.SendDataToTarget() at System.Windows.Data.BindingExpression.SourceAquired() at System.Windows.Data.BindingExpression.DataContextChanged(Object o, DataContextChangedEventArgs e) at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e) at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e) at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e) at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive) at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)

The same error also reported from this feed

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=436047

I am using vs2008 and silverlight 3 tookit RTM version. Any suggestion?

Andy
was this an answer or a question?
geofftnz