none
Binding returning to the wrong place in FlipView with VirtualizingStackPanel

    Question

  • I have a very complicated situation where I've got a control inside a flipview which displays differently depending on whether a picture is being downloaded or has finished downloading. Once the download has finished then I use an animation to fade into the downloaded picture.  I do this by setting up a binding to myself:

    BindingOperations.SetBinding(this, IsImageDownloadingProperty, new Binding() { Path = new PropertyPath("IsDownloading"), Source = newDownloadableImage });

    Then, fade out the loading indicator:

    void OnIsImageDownloadingChanged(bool oldIsImageDownloading, bool newIsImageDownloading)
    {
        if (oldIsImageDownloading && !newIsImageDownloading)
        {
            Debug.WriteLine("fading out {0} in {1}/{2}", DownloadableImage.Filename, DownloadableImage.GetHashCode(), GetHashCode());
            // downloaded, fade it out.
            Storyboard storyboard = Resources["FadeOut"] as Storyboard;
            storyboard.Begin();
        }
    }

    Unfortunately, when using the flipview with a VirtualizingStackPanel, the bindings that I have built return to the wrong object, if I have changed the selected item a couple of times in the flipview.  I can see that because I use GetHashCode() and can tell that OnIsImageDownloadingChanged is called on an object when I haven't even started downloading that image yet.

    If I use a StackPanel rather than a VirtualizingStackPanel, this problem does not exist, which suggests to me that there is some sort of confusion being caused by the VirtualizingStackPanel. Using a StackPanel is not feasible because of the memory usage with large images.

    Are there any known issues with bindings inside objects inside VirtualizingStackPanel in a FlipView?

    How do I go about getting this issue resolved?

    ...Stefan

    Friday, June 15, 2012 2:34 AM

Answers

  • We have a known bug on this problem and I expect it will be fixed in RTM.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Monday, July 02, 2012 4:49 PM
    Moderator

All replies

  • We have a known bug on this problem and I expect it will be fixed in RTM.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Monday, July 02, 2012 4:49 PM
    Moderator
  • Thanks Matt, that'd be great to have that fixed!

    Stefan

    Monday, July 02, 2012 7:19 PM
  • I am experiencing this exact same issue with the RTM version so my guess is this has not been adressed yet, can anybody confirm this?
    Thursday, October 25, 2012 9:39 AM
  • I solved putting this inside FlipView:

    <FlipView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"></StackPanel>
         </ItemsPanelTemplate>
    </FlipView.ItemsPanel>
    Wednesday, October 30, 2013 11:06 AM
  • @7Cenzo,

    that solution is okay if you don't have a lot of memory intensive content, but if you  have a picture in each item on the flip view for example that will  end up using up a lot of memory because it is not virtualizing.

    Wednesday, October 30, 2013 6:38 PM
  • @StefanOlson,

    thank you for your reply. If you need virtualization, you could set virtualization mode to standard, in this way the virtualizingstackpanel creates a new container for each item, affecting performance and not memory consumption ( i hope! ). 

    Thursday, October 31, 2013 8:04 AM