locked
BitmapImage->SetSource doesn't update Binding

    Question

  • I have a ListView with custom ItemTemplate. In the template i have Image object with Binding :
    <Image Source="{Binding AlbumArt}" Margin="0" Stretch="Uniform"/>

    Next in app i set ItemsSource to vector of Object^:
    ctrlListView->ItemsSource = m_items; (m_items is IVector<Object^>^ )

    In this vector i have my TItem objects where i have also BitmapImage and any other fields (String^). When items are already in m_items (and visible in ListView), then update to BitmapImage doesn't update ListView. How can i make ListView refreshed when i'll change anything in data (it does not work automatically) ?


    Sunday, June 3, 2012 5:26 PM

All replies

  •  

    Hello,

     

    Would you please provide us the whole codes to reproduce this issue,

     

    You can upload your project to skydriver

    http://skydrive.live.com/

     

    It is not necessary that you send out the whole of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business details from it.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, June 5, 2012 7:56 AM
  • Hello,

    You can try TWOWAY binding mode in order to propagate changes made from source to target and vice-versa. So, the <Image> tag would look something like this :-

    <Image Source="{Binding AlbumArt, Mode=TwoWay}" Margin="0" Stretch="Uniform"/>

    You can read about two way binding mode at http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.binding.mode.aspx

    Thanks,

    Sagar


    Tuesday, June 5, 2012 5:06 PM
    Moderator
  • Sagar, i've tried but didn't work. It looks like change in SetSource doesn't throw an update in UI element.
    Thursday, June 7, 2012 7:57 AM
  • Hello,

    For OneWay or TwoWay bindings, dynamic changes to the source do not automatically propagate to the target. You must implement the INotifyPropertyChanged interface on the source object. Can you please confirm if you're implementing INotifyPropertyChanged on the source collection?

    Thanks,
    Sagar

    Thursday, June 7, 2012 11:44 AM
    Moderator
  • It doesn't work for items currently in sight ... i need to scroll down and back to make images visible.
    Tuesday, June 12, 2012 5:13 PM
  • Hi,

    So previously it was not working at all and now you only see changes on the items are visible? Is there a sample can demonstrate the behavior?

    Regards,
    Sagar

    Tuesday, June 12, 2012 7:38 PM
    Moderator
  • Previously it wasn't working because of missing INotifyPropertyChanged interface. Now this interface is implemented and properly called and sometimes it will update images in sight correctly and sometimes not (it's 50/50) and need to scroll down and then back to make them appear.

    Tuesday, June 12, 2012 7:42 PM
  • Hi,

    Please send a sample code and zipped at ---    SAGARJO AT MICROSOFT.

    Please put the link of this article in the subject.

    Thanks,
    Sagar

    Tuesday, June 12, 2012 7:58 PM
    Moderator