0

I get a Catastrophic failure when a ListViews ItemSource - ObservableCollection gets loaded with less items, when using a Double Tap event. Now a wrote a very simple example of this, and I still get the same error.

This is a Windows 8.1 Store Application.

Simple Example: If I have 6 items in the listview, and I double tap item number 3. Then the ListView rebinds with 4 items. This works perfect.

But if I double tap item number 5 or 6 I get a Catastrophic failure.

Code:

    <ListView x:Name="myListView" DoubleTapped="myListView_DoubleTapped" />

    public MainPage()
    {
        this.InitializeComponent();

        List<string> list1 = new List<string>();

        list1.Add("item1");
        list1.Add("item2");
        list1.Add("item3");
        list1.Add("item4");
        list1.Add("item5");
        list1.Add("item6");

        myListView.ItemsSource = list1;
    }

    private void myListView_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
    {
        List<string> list2 = new List<string>();

        list2.Add("OterhItem1");
        list2.Add("OterhItem2");
        list2.Add("OterhItem3");
        list2.Add("OterhItem4");

        myListView.ItemsSource = list2;
    }

Update: I tried the same but with only a Tapped event, and it works fine. So it looks like this only happens with the doubletapped event.

Mat
  • 202,337
  • 40
  • 393
  • 406
  • How many times is the `DoubleTapped` event firing? I know some people have had issues with them firing more than once. It may be that you need to ensure that the `ItemsSource` is only being set once. Further, it may be easier to, instead of setting the `ItemsSource` to a new object each time to use an `ObservableCollection`(`` in this case) and manipulating that directly. – Nate Diamond Feb 06 '14 at 19:31
  • It only fires once. My original code, I am using a ObservableCollection. But is quite a big project, so to eliminate all possible problems on my side, I tried to replicate it on the smallest version possible. And I still get the problem. – Edwin le Roux Feb 10 '14 at 06:31
  • Did you find a fix for this? I'm having exactly the same issue – Oli May 30 '14 at 03:17
  • No I did not. I just redesigned the way my application work on the Front end. So that I don't require a Double Tap. – Edwin le Roux Jun 03 '14 at 10:17

1 Answers1

0

I'm pretty sure that the problem is caused by animating in new values, as I'm getting a similar thing in my app.

Frame fr = Window.Current.Content as Frame;
fr.IsEnabled = false;
   UpdateCollectionSomehow(...)
fr.IsEnabled = true;

In my code, I just disable the code before adding any more elements, and the problem went away.

Anthony Wieser
  • 4,351
  • 1
  • 23
  • 25