【发布时间】:2015-03-07 14:54:40
【问题描述】:
好的,我有一个ListView 对象,它有一个List<Filiale> 作为ItemSource,我想在对象列表更改时刷新ItemSource。 ListView 有一个个性化的ItemTemplate
现在我已经这样做了:
public NearMe ()
{
list=jM.ReadData ();
listView.ItemsSource = list;
listView.ItemTemplate = new DataTemplate(typeof(FilialeCell));
searchBar = new SearchBar {
Placeholder="Search"
};
searchBar.TextChanged += (sender, e) => {
TextChanged(searchBar.Text);
};
var stack = new StackLayout { Spacing = 0 };
stack.Children.Add (searchBar);
stack.Children.Add (listView);
Content = stack;
}
public void TextChanged(String text){
//DOSOMETHING
list=newList;
}
正如您在 TextChanged 方法中看到的,我为前一个列表分配了一个新列表,但视图中没有任何变化。
在我创建的ViewCell 中,我为标签的文本字段分配了SetBinding
【问题讨论】:
-
您可以从 INotifyPropertyChanged 继承您的视图模型(如果您正在使用)
-
看看这个link 可能对你有帮助..
标签: c# .net xamarin xamarin.forms