/// <summary> /// 执行过滤操作 /// </summary> private void FireFiltering() { if (this._curProgress == CLCProgress.KeyPressed) { //输入后异步触发事件 this.Dispatcher.BeginInvoke((Action) delegate { try { this._curProgress = CLCProgress.LazyFiltering; // 绑定新的数据源 this._listView.Filter = item => { string match = this.GetDisplay(item); //在数据源中按输入的文字查找符合要求的项 var result = match.Contains(this.Text) || PinYinConverter.Convert(match).Contains(this.Text) || PinYinConverter.GetShortPY(match).Contains(this.Text); return(result); }; this.IsDropDownOpen = true; } finally { this._curProgress = CLCProgress.NotStarted; } }, DispatcherPriority.ApplicationIdle); } }
/// <summary> /// 开始控件的 KeyPressed 流程。 /// (下一步:文本改变。) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartFilterTimer() { this._curProgress = CLCProgress.KeyPressed; //如果是用户开始输入,则开始计时。(ResetTimer) this._lazyFilterInterval.Stop(); this._lazyFilterInterval.Start(); }