【问题标题】:ReactiveList and WhenAnyReactiveList 和 WhenAny
【发布时间】:2013-11-26 19:00:53
【问题描述】:

我在ReactiveLists 中保存了许多检查列表,其中包含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。知道我应该做什么吗?

【问题讨论】:

    标签: c# reactiveui


    【解决方案1】:

    这是测试某人何时设置列表本身,即何时:

    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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-04
      相关资源
      最近更新 更多