Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 向ListBox.ItemsSource添加新项目_Windows Phone 7_Listboxitem - Fatal编程技术网

Windows phone 7 向ListBox.ItemsSource添加新项目

Windows phone 7 向ListBox.ItemsSource添加新项目,windows-phone-7,listboxitem,Windows Phone 7,Listboxitem,我正在开发一个Windows Phone应用程序 我有一个包含以下C#源代码的列表框: System.Collections.Generic.IEnumerable<OpenGame> items; ... GamesList.ItemsSource = items; System.Collections.Generic.IEnumerable项; ... GamesList.ItemsSource=物品; 如果我想在游戏列表中添加一个新项目(一个新的OpenGame对象),

我正在开发一个Windows Phone应用程序

我有一个包含以下C#源代码的列表框:

System.Collections.Generic.IEnumerable<OpenGame> items;

...

GamesList.ItemsSource = items;
System.Collections.Generic.IEnumerable项;
...
GamesList.ItemsSource=物品;

如果我想在游戏列表中添加一个新项目(一个新的OpenGame对象),我该怎么做呢?

我想你可以在这个帖子中找到答案:

我想你可以在这个帖子中找到你的答案:

使用ObservableCollection而不是IEnumerable,然后可以使用Add方法

IEnumerable用于不希望添加或删除成员的静态列表


ObservableCollection是为绑定到列表框和类似控件的列表而设计的。除了允许您添加和删除项目外,它还将通知列表框,以便在集合更改时更新它。

使用ObservableCollection而不是IEnumerable,然后您可以使用add方法

IEnumerable用于不希望添加或删除成员的静态列表

ObservableCollection是为绑定到列表框和类似控件的列表而设计的。除了允许您添加和删除项目外,它还将通知列表框,以便在集合更改时更新列表框