我在 ReactiveLists
中保存了许多检查 list ,其中包含 ChangeTrackingEnabled = true
。我只想在每个列表中至少检查一个项目时启用我的 OkCommand。
此外,我还想确保用有效的字节值填充了其他各种属性。
我尝试执行以下操作,但不起作用:
this.OkCommand = new ReactiveCommand(this.WhenAny(
x => x.Property1,
x => x.Property1,
x => x.Property1,
x => x.List1,
x => x.List2,
x => x.List3,
(p1, p2, p3, l1, l2, l3) =>
{
byte tmp;
return byte.TryParse(p1.Value, out tmp) &&
byte.TryParse(p2.Value, out tmp) &&
byte.TryParse(p3.Value, out tmp) &&
l1.Value.Any(x => x.IsChecked) &&
l2.Value.Any(x => x.IsChecked) &&
l3.Value.Any(x => x.IsChecked);
}));
似乎属性更改通知没有传播到 WhenAny。知道我应该做什么吗?
最佳答案
这是在有人设置列表本身时进行测试,即当:
this.List1 = new ReactiveList<Foo>();
相反,你想要这样的东西:
this.WhenAnyObservable(x => x.List1.ItemChanged, x => x.List2.ItemChanged)
.Where(x => x.PropertyName == "IsChecked")
.Select(_ => List1.Any(x => x.IsChecked) && List2.Any(x => x.IsChecked));
关于c# - ReactiveList 和 WhenAny,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20225705/