2013-09-25 49 views

回答

0

你需要声明你的ItemSource为您longlistselector为类型的ObservableCollection,所以,当你,你会longlistselector响应的变化相应地修改你的ItemSource。

牛逼可能是你的自定义类型,例如:

//Photo is my custom class 
ObservableCollection<Photo> photos; 

示例代码:

//Declare itemsource  
ObservableCollection<string> list; 

//Bind to longlistselector dynamically somewhere in code 
longlistselector.ItemSource = list; 

//Add items into your source 
list.Add("test1"); 
list.Add("test2"); 
list.Add("test3"); 

//Delete items 
list.RemoveAt(input item index here); 

//OR 

list.Remove(item); //if you're able to retrieve item ref; 

而在你的XAML:

//Notice the {Binding } syntax below for ItemSource property 
<phone:LongListSelector ItemsSource="{Binding }" SelectionChanged="longListSelector_SelectionChanged" Name="longListSelector" /> 

希望它很适合你。

一个代码示例供参考:

http://code.msdn.microsoft.com/wpapps/LongListSelector-Demo-45364cc9

+0

Thanx男子它帮助:) –

0

您可以使用简单的方法RemoveAt(位置)

+0

或删除(对象)如果实现可序列化 – Frank