2009-06-18 4 views
6

나는이 같은 콤보 상자 내에서 뷰 모델 ObservableCollectoin 속성에서 얻을 내 모든 고객을 표시 해요 : XAML에서 ObservableCollection의 항목 수를 얻는 방법은 무엇입니까?

<ComboBox 
    ItemsSource="{Binding Customers}" 
    ItemTemplate="{StaticResource CustomerComboBoxTemplate}" 
    Margin="20" 
    HorizontalAlignment="Left" 
    SelectedItem="{Binding SelectedCustomer, Mode=TwoWay}"/> 

다른 뷰 모델 속성을 만들지 않고 ObservableCollection에 의 항목 수를 얻을 수있는 방법이 있나요, 예 : 이 같은 :

의사 코드 :

<TextBlock Text="{Binding Customers.Count()}"/> 

답변

16

ObservableCollection에 유형은 당신이 사용할 수있는 Count 속성을 노출합니다. ObservableCollection이이 속성에 대한 업데이트를 UI에 알리기 위해 PropertyChanged 이벤트를 발생시키는 지 알 수 없습니다.

+4

괜찮습니다. 예, ObservableCollection이 변경되면 계속 업데이트됩니다. –

관련 문제