locked
ListViewItem (ItemSource) Remove error RRS feed

  • Question

  • I'm having a frustrating problem:

    try
                {
                    if (buttonMap.Values.Contains(null) && first11.SelectedItem != null)
                    {
                        foreach (KeyValuePair<Button, Player> pair in buttonMap)
                        {
                            if (pair.Value == null)
                            {
                                string lastName = (String)first11.SelectedItem;
                                Player player = new Player("", lastName, "");
                                pair.Key.Content = player.getLastName();
                                //pair.Key.Tag = player.getNo();
                                buttonMap[pair.Key] = player;
                                pair.Key.Visibility = Visibility.Visible;
                                break;
                            }
                        }
                    }
                    first11OC.Remove(first11.SelectedItem); // crashes here
                }
                catch
                {
                    return;
                }

    At the "first11OC.Remove(first11.SelectedItem), the program crashes and takes me to a page of code noted as "App.g.i.cs" shouting something about the debugger. 

    What is going on here?

    (first11OC is an ItemSource, an instance of ObservableCollection<object>)



    Friday, August 23, 2013 1:14 PM

Answers

  • There's an exception inside the "e" parameter when the app.g.i.cs page is displayed in VS.  What is that exception?

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

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, August 23, 2013 2:13 PM
    Moderator

All replies

  • There's an exception inside the "e" parameter when the app.g.i.cs page is displayed in VS.  What is that exception?

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

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, August 23, 2013 2:13 PM
    Moderator
  • It's blank, thats what's confusing me.
    Friday, August 23, 2013 4:31 PM
  • Can you put your project on skydrive, so I can look at it?

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

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, August 23, 2013 5:02 PM
    Moderator