0

I have a TagTypeController class that provides a collection view to a controller for a WPF UserControl, which holds a private reference to the collection view.

_ttController = new TagTypeController(_isProd);
CollectionView tagTypeList = _ttController.getTagTypes();

In the TagTypeController, when creating the CollectionView, I'm setting the filter delegate

if (_tagTypeList == null)
    _tagTypeList = new CollectionView(CollectionViewSource.GetDefaultView(_tagTypeTable));
    _tagTypeList.Filter = new Predicate<object>(filterTagTypes);

I would like to locate all the logic for filtering, etc. of that collectionview in the TagTypeController class. The problem is, when the text changes in the TextBox of the UserControl, I'm responding to that event by delegating to the controller for the UserControl. When I ask the tagTypeList to refresh, it does not call the filterTagTypes method. Is it not possible to have the filter delegate in a different class?

Thanks.

EDIT: adding requested code

//parse the string to get just the portion after the last comma and space
Int32 _lastComma = _tempText.LastIndexOf(",");
_ttController.searchText = _tempText.Substring(_lastComma + 1).Trim();

tagTypeList.Refresh();

iis express 7.5 roaming profile visual studio 2010 sp1

Unless I redirect the My Documents folder to a local copy IIS Express fails to start with the following error message: Filename: redirection.config Error: Cannot read configuration file

This happens when starting a new web project from studio or even is I just double click on the iisexpress.exe file.

Any way around this or must I continue to redirec the My Documents folder

4

1 に答える 1

1

問題は、イベントではなくフィルター述語を使用している可能性があると思います。CollectionViewのドキュメントを見ると、次のように書かれています。

ビュー オブジェクトが CollectionViewSource オブジェクトに由来する場合は、Filter イベントのイベント ハンドラーを設定してフィルター処理ロジックを適用します。

したがって、プロパティを設定する代わりに、イベント ハンドラーを使用して、コードが次のようになるようにします。

_tagTypeList.Filter += FilterTagTypesHandler;

どこFilterTagTypesHandlerで次のように定義されています

private void FilterTagTypesHandler(object sender, FilterEventArgs e){
  //do filtering
}

CollectionViewもう 1 つの可能性は、 の結果をキャストするのではなく、新しい を作成していることですGetDefaultView()。これを行うと、おそらくコントロールへの接続が失われます。CollectionViewSource のドキュメントを見ると、それを使用する推奨方法は次のとおりです。

myCollectionView = (CollectionView)
    CollectionViewSource.GetDefaultView(rootElem.DataContext);
于 2011-05-02T22:27:08.393 に答える