I am trying to prevent the user from continuing until they have selected at least one item in a list. The list is a bound to a separate view control inside the main view and the list viewmodel has a bool with 2 way binding to a checkbox in its view. The command to continue is part of the main viewmodel so to try and listen to changes I am creating a derived list
tempList = this.WhenAnyValue(x => x.Items,
(layers) => layers == null ? Enumerable.Empty<bool>() : layers.CreateDerivedCollection(x => x.Selected))
.ToProperty(this, x => x.TempList);
CanContinue = this.WhenAnyValue(m => m.CollectionInfo, m => m.TempList,
(collectionDatabase, tempItems) =>
{
if (collectionDatabase == null || tempItems == null) return false;
var temp = tempItems.Any(x => x == true);
return temp;
});
The problem is that the TempList never changes. I can see the Selected property changing on the child viewmodel but that's it.
I have also tried assigning the TempList as
tempList = Items.Changed.Select(_ => Items.Select(gr => gr.Selected))
.ToProperty(this, x => x.TempList);
Anyone have any suggestions? The data model is out of my control as in the real application I'm loading sets of data from disk that can contain one or more sets of data. I've got a sample app that demonstrates the issue if you want to try it for yourself.