-
[WPF] ObservableCollection FilterC#/WPF 2023. 5. 19. 17:31
var filterView = CollectionViewSource.GetDefaultView(AppManager.AppsListBoxData); if (filterView.CanFilter) filterView.Filter = TypeNameFilter;
private bool TypeNameFilter(object obj) { var appItem = obj as AppsItem; if(TypeNameList.Count> 0) { return TypeNameList.Contains(appItem.ItemType); } return false; }
C#, WPF, MVVM 패턴에서 ObservableCollection Filtering 하는 방법.
1. ObservableCollection 에서 View 를 생성한다. 2. 생성된 View에 Filter를 적용한다. 3. 조건이 변경되면 View를 Refresh해준다. 일반적인 Collection에서 추가해줘야 하는것은... View 를 구해서 Filter를 적용하는
zinzza.tistory.com
728x90'C# > WPF' 카테고리의 다른 글
[WPF] Access view control from viewmodel (0) 2023.05.31 [WPF] ReadOnly Property (0) 2023.05.24 [WPF] 인터넷 link (0) 2023.05.17 [WPF] initializecomponent(); 에러 (0) 2023.05.12 [WPF] ObservableCollection and Item PropertyChanged (0) 2023.04.20 댓글