I have an ObservableCollection<T>, T object has nested ObservableCollection<U>, U class has a IsCompleted boolean. How can I collect on my ViewModel the Progress which is the % of completed.
TestPage:
<ProgressBar Progress="{Binding Progress}" />
class TestViewModel
{
[ObservableProperty]
public ObservableCollection<T> _items;
public double Progress
{
get
{
return ((double)Items.NestedItems.SelectMany(e => e.NestedItems).Count(s => s.IsCompleted) / (double)Items.Sum(e => e.NestedItems.Count));
}
}
void Init()
{
// load data
}
}
class T
{
public ObservableCollection<U> NestedItems { get; set; } = new ObservableCollection<U>();
}
class U :ObservableObjectBase
{
bool IsCompleted {get;set;}
}
So with Progress I am trying to collect the percentage of IsCompleted of the nested item.
The problem is Progress is not updated at all.