I'm displaying all of my customers which I get from a ViewModel ObservableCollectoin property within a ComboBox like this:
<ComboBox
ItemsSource="{Binding Customers}"
ItemTemplate="{StaticResource CustomerComboBoxTemplate}"
Margin="20"
HorizontalAlignment="Left"
SelectedItem="{Binding SelectedCustomer, Mode=TwoWay}"/>
Is there a way to get the number of items in the ObservableCollection without creating another ViewModel property, e.g. something like this:
PSEUDO-CODE:
<TextBlock Text="{Binding Customers.Count()}"/>
From stackoverflow
-
the ObservableCollection type exposes a Count Property which you can use. I don't know if ObservableCollection raises the PropertyChanged event in order to inform the ui about updates to this property though.
Edward Tanguay : ok it's just this:, and yes it seems to constantly update when the ObservableCollection changes, nice.
0 comments:
Post a Comment