동일한 상위 유형에서 모두 상속되는 3 가지 유형의 객체로로드중인 ListBox가 있습니다. CollectionBoxSource를 사용하여 유형에 따라 ListBox의 객체를 필터링하고 싶지만 필터 작성에 문제가 있습니다. 에서Silverlight 4 CollectionViewSource ListBox 데이터 유형 기반 필터
<UserControl.Resources>
<CollectionViewSource x:Key="eventsViewSource"
Source="{Binding lifeCycleEvents}" >
<CollectionViewSource.SortDescriptions>
<compMod:SortDescription PropertyName="Date" Direction="Ascending"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</UserControl.Resources>
<ListBox Name="lstEventHistory" ItemsSource="{Binding Source={StaticResource eventsViewSource}}">
...
</ListBox>
코드 숨김 내가 객체의 관찰 컬렉션 비동기 메서드 호출에서 반환 된로드 해요 : : 이제
private ObservableCollection<LifeCycleEvent> lifeCycleEvents;
...
lifeCycleEvents= e.Result;
CollectionViewSource eventsViewSource = this.Resources["eventsViewSource"] as CollectionViewSource;
eventsViewSource.Source = lifeCycleEvents;
내가 좋아하는 것 다음과 같이
내 XAML입니다 사용자가 UI에서 클릭 할 체크 박스를 기반으로 특정 유형의 객체 만 표시하는 필터를 작성합니다.
eventsViewSource.Filter = new Predicate<object>(rmaFilter);
public bool rmaFilter(object item)
{
if(item.GetType() == typeof(RmaEvent))
return true;
else
return false;
}
이 다음과 같은 오류를 제공합니다 : "이벤트 System.Windows.Data.CollectionViewSrouce.Filter는 +의 왼쪽에 나타날 수
다음 하나 개의 필터를 작성에 실패한 시도 = 또는 - = ".
필자가 원하는대로 자습서를 찾을 수 없었습니다. Silverlight에서는 존재하지 않는 기본보기를 사용합니다. 내가 본 자습서 중 하나를 찾을 수 있습니다 here
어떤 팁 감사합니다!