问题描述
我公司拥有一批在 ReactiveLists
举行支票列出了有 ChangeTrackingEnabled = TRUE
。我想只启用我OkCommand当存在至少一个项目中的每个列表进行检查。
I have a number of check lists held in ReactiveLists
that have ChangeTrackingEnabled = true
. I want to only enable my OkCommand when there is at least one item checked in each list.
在另外还有一些欲确保与填充在各种其它属性。有效的字节值
In addition there are various other properties that I want to ensure are filled in with a valid byte value.
我试着做以下,但它不工作:
I've tried doing the following but it doesn't work:
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。任何想法,我应该做?
It seems the property change notifications aren't being propagated to WhenAny. Any idea what I should be doing?
推荐答案
这是测试当某人的设置的名单本身,即当:
This is testing when someone sets the list itself, i.e. when:
this.List1 = new ReactiveList<Foo>();
相反,你想要的东西,如:
Instead, you want something like:
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));
这篇关于ReactiveList和WhenAny的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!