2014-04-09 2 views
1

내가 콤보 상자가 itemsource는 두 가지 방법으로 바인더 제본 될 수 있음을 보았다 바인딩을 직접 대 :WPF 콤보 itemssource collectionviewsource

직접를

CollectionViewSource

<Window x:Class="WpfApplication25.Window1" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 

<Window.Resources> 
    <CollectionViewSource x:Key="list" Source="{Binding Items}"/> 
</Window.Resources> 

<ComboBox Name="k" ItemsSource="{Binding Source={StaticResource list}}"/> 

<ComboBox Name="k" ItemsSource="{Binding Path=Mylist}"/> 

바인딩 어떤 두 가지 방법의 차이점은 무엇입니까?

답변

3

CollectionViewSource로 필터링하거나 정렬 할 수 있습니다.

필자는 가능한 경우 직접 바인딩을 선호하지 않습니다.

ObservableCollection 또는 INotify와 같은 것으로보기에 항상 선택되지는 않습니다.

내가보기를 새로 고쳤을 때도 나는 지나치지 않았습니다.

나는 CollectionViewSource를 사용하지 말고 단지 필요할 때만 사용한다고 말하지는 않습니다.

공격 받기 전에 많은 사람들이 CollectionViewSource에 문제가 없었을 것이라고 확신합니다.

How to: Sort and Group Data Using a View in XAML