I have a simple Label
that should include the bound .Count
value of a Property of an ObservableCollection
.
The thing is, that the result is always 0 (zero). The same Property is bound to a DataGrid, which works perfectly and even updates if something has changed in the Collection.
What am I doing wrong here?
Here is my code:
<Label ContentStringFormat="Members: {0}">
<Label.Content>
<Binding Path="MembersList.Count" Mode="OneWay" UpdateSourceTrigger="Default" />
</Label.Content>
</Label>
The Property looks like:
public static ObservableCollection<Mitglied> MembersList { get; set; }
I can only assume you've not actually added any items to the collection. If you think you are, you'll have to give us a more complete repro.
This works perfectly for me:
MainWindow.xaml
MainWindow.xaml.cs
BTW, this is far more succinct:
You can try This...
MainWindow.Xaml.cs->
MainWindow.xaml->
Hi You will have to Notify on CollectionChanged then it will Work
DataGrid uses this collectionChanged and hence working for DataGrid.