如何在文本框中更改字符集的列表框中实现过滤器文本

时间:2011-12-03 17:09:45

标签: windows-phone-7

如何在wp7中实现Bing搜索,通过在文本框中输入字符我在列表框中有数据列表我应该能够从列表中过滤数据。

3 个答案:

答案 0 :(得分:0)

从Silverlight Toolkit for Windows Phone检查自动完成控件(它位于codeplex上)

答案 1 :(得分:0)

除了使用AutoCompleteBox之外,您应该使用CollectionViewSource http://www.windowsphonegeek.com/news/wp7-Collectionviewsource-filtering

答案 2 :(得分:0)



//JQuery: 
 //mobile - netbanking search
 $(document).on('keyup', '#filter', function (e) {
	// Retrieve the input field text and reset the count to zero
	var filter = $(this).val();

	//Regex created to find value in list.
	var pattern = new RegExp(filter, "i");


	// Loop through the comment list
	$(".list").each(function () {
		// If the list item does not contain the text phrase fade it out

		//Trim space from variable value.
		var str = $(this).text().trim();

		if (str.search(pattern) < 0) {
			$(this).fadeOut();
			//Show the list item if the phrase matches and increase the count by 1
		} else {
			$(this).show();
		}
	});
}); 
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
JQuery Solution: 
HTML will be: 

<div class="yourlist">

	<input name="" id="filter" type="text" placeholder="Search list" onkeyup="this.setAttribute('value', this.value);" value="">

		<div class="list" style="display: block;">
			Abc
		</div>
		<div class="list" style="display: block;">
			xyz
		</div>
		<div class="list" style="display: block;">
			qwe
		</div>
</div>
&#13;
&#13;
&#13;