2013-09-25 47 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