请帮助重现...到可搜索的长列表选择器。
如何在Windows Phone 8平台中为长列表选择器创建可搜索文本框。
感谢任何帮助
提前感谢。
答案 0 :(得分:0)
//查看 因此,创建TextBox和按钮=>
<StackPanel Orientation="Horizontal">
<TextBox Width="200" Text="{Binding Text,Mode=TwoWay}"></TextBox>
<Button Command="{Binding Search}"></Button>
</StackPanel>
//视图模型
private List<AlphaKeyGroup<CountryInfo>> _dataSource;
public List<AlphaKeyGroup<CountryInfo>> DataSource
{
get { return _dataSource; }
set
{
_dataSource= value;
RaisePropertyChanged(() => DataSource);
}
}
private string _searchText;
public string SearchText
{
get { return _searchText; }
set {
_searchText= value;
RaisePropertyChanged(() => SearchText);
}
}
public RelayCommand Search {get;set;}
//构造
Search = new RelayCommand(setSearchList);
//了Methode
private void setSearchList(){
if(string.isNullOrEmpty(SearchText)){
DataSource = AlphaKeyGroup<CountryInfo>.CreateGroups(CountryInfoList, System.Threading.Thread.CurrentThread.CurrentUICulture, (CountryInfo s) => { return s.Name; }, true);
}else{
var listCopy= CountryInfoList.where(item=> item.Name == SearchText).ToList();
DataSource = AlphaKeyGroup<CountryInfo>.CreateGroups(listCopy, System.Threading.Thread.CurrentThread.CurrentUICulture, (CountryInfo s) => { return s.Name; }, true); }
}
您的itemSource是DataSource属性。